tailwind+vue实现切换深色模式

tailwind.config.js

Copy
export default {
darkMode: "class",
...
};

App.vue

Copy


<div
class="w-screen h-screen bg-white dark:bg-gray-800 transform transition-all duration-300"
>
深色模式
浅色模式





import { ref } from "vue";

const isdark = ref(false);


效果