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

Vue3新增加的css语法糖

一、deep
<template><div class=""><el-input /> </div>
</template>
<style scoped>
/* 样式穿透 */
:deep input {background: red;
}
</style>
二、slotted

子组件修改插槽里面的样式

<template><div class=""><child><div></div></child></div>
</template><style scoped>
/* 修改插槽样式 */
:slotted(div) {background: red;
}
</style>
三、global

scoped里面依然可以写全局样式

<template><div class=""></div>
</template>
<style scoped>
/* 全局样式 */
:global(div) {background: red;
}
</style>
四、v-bind
<template><div class=""></div>
</template>
<script setup lang="ts">
import { ref } from "vue"
const bag = ref<string>('red')
</script>
<style scoped>
/* 动态样式*/
div {background: v-bind(bag)
}
</style>
五、module
<!-- 将生成的 CSS 类作为 $style 对象的键暴露给组件 -->
<template><div :class="$style.title"></div> 
</template><style module>
.title {color: red;
}
</style><!-- 将生成的 CSS 类作为 jx 对象的键暴露给组件-->
<template><div :class="jx.title"></div> 
</template>
<style module="jx">
.title {color: red;
}
</style>

可以通过获取

<script setup lang="ts">
import { useCssModule } from "vue"
const jx = useCssModule('jx')
console.log(jx.title);
const user = `<div class="${jx.title}">12313</div>`
</script>
<style module="jx">
.title {color: red;
}
</style>

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

相关文章:

  • Windows安装Vmware 虚拟机
  • uniapp地图手动控制地图scale
  • Kotlin学习之函数
  • 若依启动步骤
  • qt-C++笔记之两个窗口ui的交互
  • Redis-核心数据结构
  • 设计模式—结构型模式之外观模式(门面模式)
  • CentOS Stream 9-使用 systemd 管理自己程序时自定义日志路径
  • 动态页面调研及设计方案
  • 鸿蒙4.0开发笔记之DevEco Studio之配置代码片段快速生成(三)
  • HarmonyOS真机调试报错:INSTALL_PARSE_FAILED_USESDK_ERROR处理
  • webSocket基于面向对象二次封装
  • 【Web】PHP反序列化的一些trick
  • 【测试功能篇 01】Jmeter 压测接口最大并发量、吞吐量、TPS
  • 代码随想录算法训练营第四十九天| 123.买卖股票的最佳时机III 188.买卖股票的最佳时机IV
  • 11.20 知识总结(choices参数、MVC和MTV的模式、Django与Ajax技术)
  • 深度学习二维码识别 计算机竞赛
  • C#关于TimeSpan结构的使用和获取两个时间差
  • Git分支管理
  • 《视觉SLAM十四讲》-- 建图
  • 智能配电箱柜管理系统
  • 聊聊近些年 CPU 在微架构、IO 速率上的演进过程
  • PS学习笔记——移动工具
  • 信息中心网络提出的背景、研究现状及研究内容
  • 【计算机视觉】24-Object Detection
  • 【mac 解决eclipse意外退出】
  • mysql innodb buffer pool缓冲池命中率和命中了哪些表?—— 筑梦之路
  • 牛掰的dd命令,cpi0配合find备份(不会主动备份),od查看
  • pip list 和 conda list的区别
  • 多目标应用:基于多目标灰狼优化算法MOGWO求解微电网多目标优化调度(MATLAB代码)