๐ฉโ๐ป element ui plus ๆ้ปๆจกๅผ
็ๆฌโ
- vue: 3.2.41
- vite: 3.2.0
- typescript: 4.6.4
- element-plus: 2.3.12
ๅฎ่ฃโ
ๅ ๅฎ่ฃ vueUseโ
vueUse ้กไผผ react ไธญ็ hooks
yarn add @vueuse/core
ๅ ๅ ฅ้้โ
ๆผ App.vue
<script setup lang="ts">
import { useDark } from "@vueuse/core";
const isDark = useDark();
</script>
<template>
<div>
<button @click="toggleDark()">
ๆฏๅฆ็บๆ้ปๆจกๅผ: {{ isDark }}
</button>
</div>
<main>
<router-view />
</main>
</template>
ๅ ๅ ฅ cssโ
ๆผ style.css
html.dark {
/* ่ๆฏ้ก่ฒ */
--af-bg-color: #000000;
}
ๅ ๅ ฅๆทฑ่ฒไธป้กโ
import { createApp } from "vue";
import { createPinia } from "pinia";
import './style.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import ElementPlus from 'element-plus'
import router from "./router/index";
import App from "./App.vue";
const app = createApp(App);
app.use(router).use(createPinia()).use(ElementPlus, { size: 'small', zIndex: 3000 }).mount("#app");