【Element】Vue3 中快捷设置 Element 主题色

文章介绍了如何在Vue应用中安装并使用TinyColor库进行颜色转换,同时检测浏览器版本并在低版本Firefox上显示警告。还展示了如何监听用户选择的主题色并动态更新相关CSS变量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

直接放代码,很简单

需要安装一个颜色转换的库 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()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值