使用Electron开发桌面程序时,一般都会自定义窗口标题行,并实现拖拽窗口的功能,要实现该功能非常简单,只需要一个CSS即可:
css-webkit-app-region: drag;
2800
冲上了 3300
,创业板更是大涨超 40%
,这是回光返照还是起死回生?我们拭目以待。PS:怎样才能做到反向操作呢?怎么才能知道自己的真实想法呢?
不啰嗦,直接看代码,代码下面会有详细说明。
html<template>
<div>
<v-switch
color="warning"
v-model="themeValue"
@update:modelValue="toggleTheme()"
hide-details
inset
>
<template v-slot:label>
<v-icon
:icon="themeValue ? 'mdi-emoticon-cool-outline' : 'mdi-weather-night'"
:color="themeValue ? 'warning' : 'white'"
></v-icon>
</template>
</v-switch>
</div>
</template>
<script setup lang="ts">
// 切换主题开关组件,只负责切换逻辑,不关心主题初始化逻辑
import { useTheme } from "vuetify";
const theme = useTheme(); // vuetify 的 theme 属性
const themeValue = ref(theme.global.name.value == "light"); // 根据theme控制switch开关的变量
const toggleTheme = () => {
const to = themeValue.value ? "light" : "dark";
theme.global.name.value = to;
localStorage.setItem("theme", to);
};
</script>
<style scoped></style>
使用Vue自动封装组件时,有时会需要传入一些钩子函数,用于实现一些特殊功能的回调,最常见的就是父子组件交互,有时传入的函数会在组件初始化自动执行,这是为什么?
答案:你在传递函数时使用了()
!