当前位置: 首页 > news >正文

vue3全局控制Element plus所有组件的文字大小

项目框架vue-右上角有控制全文的文字大小

实现:

只能控制element组件的文字及输入框等大小变化,如果是自行添加div,text, span之类的控制不了。

配置流程

APP.vue

使用element的provide,包含app

<el-config-provider :locale="locale" :size="size">
<template><el-config-provider :locale="locale" :size="size"><!-- 开启水印 --><el-watermarkv-if="watermarkEnabled":font="{ color: fontColor }":content="defaultSettings.watermarkContent"class="wh-full"><router-view /></el-watermark><!-- 关闭水印 --><router-view v-else /></el-config-provider>
</template><script setup lang="ts">
import { useAppStore, useSettingsStore } from "@/store";
import defaultSettings from "@/settings";
import { ThemeEnum } from "@/enums/ThemeEnum";const appStore = useAppStore();
const settingsStore = useSettingsStore();const locale = computed(() => appStore.locale);
const size = computed(() => appStore.size);
const watermarkEnabled = computed(() => settingsStore.watermarkEnabled);// 明亮/暗黑主题水印字体颜色适配
const fontColor = computed(() => {return settingsStore.theme === ThemeEnum.DARK? "rgba(255, 255, 255, .15)": "rgba(0, 0, 0, .15)";
});
</script>

点击界面的文字大小时,更新全局变量变更size

const appStore = useAppStore();
const size = computed(() => appStore.size);

 useAppStore() 点击按钮时,会调用到的事件

function changeSize(val: string) {size.value = val;
}

 切换:操作日记是一个div不会变,表格是el-table,会根据大小变化。

http://www.lryc.cn/news/329498.html

相关文章:

  • 区间预测 | Matlab实现带有置信区间的BP神经网络时间序列未来趋势预测
  • Matlab中的脚本和函数
  • 使用 nohup java - jar 不输出nohup日志
  • Linux系统中安装一些常用的插件备用
  • 笔记本电脑上部署LLaMA-2中文模型
  • 百度云加速方法「Cheat Engine」
  • SOC内部集成网络MAC外设+ PHY网络芯片方案:PHY芯片基础知识
  • openGauss 6.0.0-RC1 版本正式发布!
  • 【JVM】关于JVM垃圾回收
  • Unity照片墙简易圆形交互效果总结
  • Unity2018发布安卓报错 Exception: Gradle install not valid
  • 蓝桥杯省赛刷题——题目 2656:刷题统计
  • Python爬虫之异步爬虫
  • 【Web】NSSCTF Round#20 Basic 个人wp
  • 【Java笔记】实现延时队列1:JDK DelayQueue
  • npm淘宝镜像源切换
  • ENet——实时语义分割的深度神经网络架构与代码实现
  • 游戏领域AI智能视频剪辑解决方案
  • 腾讯云轻量2核2G3M云服务器优惠价格61元一年,限制200GB月流量
  • leecode 331 |验证二叉树的前序序列化 | gdb 调试找bug
  • 服务器安全事件应急响应排查方法
  • 数码视讯Q7盒子刷armbian或emuelec的一些坑
  • 2_2.Linux中的远程登录服务
  • Spring Boot集成JPA快速入门demo
  • 深度学习理解及学习推荐(持续更新)
  • 【C语言】贪吃蛇【附源码】
  • 【技巧】压缩文件如何设置“自动加密”?
  • 内网穿透时报错【Bad Request This combination of host and port requires TLS.】的原因
  • 计算机网络:物理层 - 信道复用
  • 【算法集训】基础算法:滑动窗口