直接放代码,很简单
需要安装一个颜色转换的库 TinyColor
TinyColor-npm
代码
app.vue
<script setup lang="ts">
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
import {
computed, onMounted, watch } from 'vue';
import {
ElNotification } from 'element-plus';
import {
useUserStore } from '@/store/index';
import tinycolor from 'tinycolor2';
const userStore = useUserStore();
const color = computed(() => userStore.baseForm.color);
// 监听浏览器版本
// @ts-ignore
import getBsInfo from 'browser-tag';
const bsInfo = getBsInfo()