【Vue3】CSS 新特性

news/2024/5/21 5:54:10

:slotted

<template>
<!--  App.vue--><Son ><div class="a">我要插入了</div></Son>
</template><script setup lang="ts">
import Son from './components/Son.vue'
</script><style></style>
<template>
<!--  Son.vue-->插槽:<slot></slot>
</template><script setup lang="ts"></script>
<style scoped>
:slotted(.a) {color: cadetblue;
}
</style>

在这里插入图片描述

:global

<template>
<!--  App.vue--><Son ><div class="a">我要插入了</div></Son>
</template><script setup lang="ts">
import Son from './components/Son.vue'
</script><style scoped>
:global(div) {color: aqua;
}
</style>

v-bind

<template>
<!--  App.vue--><div class="c1">动态css1</div><div class="c2">动态css2</div>
</template><script setup lang="ts">
import {ref} from "vue";
const style1 = ref('lightblue')
const style2 = ref({color: 'lightgreen'
})
</script><style scoped>
.c1 {color: v-bind('style1')
}
.c2 {color: v-bind('style2.color')
}
</style>

在这里插入图片描述

module

<template><!--  App.vue--><div :class="heo.c1">动态css1</div><div :class="[heo.c2, heo.c1]">动态css2</div>
</template><script setup lang="ts">
import {ref} from "vue";</script><style module="heo">
.c1 {color: lightblue
}.c2 {border: 1px solid black;
}
</style>

在这里插入图片描述
如果 module 没有指定名字<style module>,则默认使用:class="$style.c1"

此外,他还有自定义hook useCssModule

在这里插入图片描述

:deep

:deep() 和 样式穿透

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.cpky.cn/p/10140.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

vue+element模仿实现云码自动验证码识别平台官网

一、项目介绍 项目使用传统vue项目结构实现&#xff0c;前端采用element实现。 element官网&#xff1a;Element - The worlds most popular Vue UI framework 云码官网地址&#xff1a;云码-自动验证码识别平台_验证码识别API接口_免费验证码软件 项目截图&#xff0c;支持…

计算机网络

OSI七层模型 TCP/IP四层模型 具体是应用层,传输层,网络层,网络接口层 应用层 应用层,主要提供两个应用程序之间信息交换的服务, 定义了信息交换的格式,消息交换的格式, 消息会给下一层传输层来传输. 应用层交互的数据单元叫做报文 还定义了网络通信规则, 对于不同网络应用需要不…

备战蓝桥杯————二分查找(二)

引言 在上一篇博客中&#xff0c;我们深入探讨了二分搜索算法及其在寻找数组左侧边界的应用。二分搜索作为一种高效的查找方法&#xff0c;其核心思想在于通过不断缩小搜索范围来定位目标值。在本文中&#xff0c;我们将继续这一主题&#xff0c;不仅会回顾二分搜索的基本原理&…

悟彻菩提真妙理,断魔归本合元神

解法&#xff1a; 介绍一下floor函数&#xff0c;ceil函数&#xff0c;round函数 分别是向下取整&#xff0c;向上取整&#xff0c;四舍五入 #include<iostream> #include<vector> #include<algorithm> #include<cmath> using namespace std; #defi…

GPT-4技术解析:与Claude3、Gemini、Sora的技术差异与优势对比

【最新增加Claude3、Gemini、Sora、GPTs讲解及AI领域中的集中大模型的最新技术】 2023年随着OpenAI开发者大会的召开&#xff0c;最重磅更新当属GPTs&#xff0c;多模态API&#xff0c;未来自定义专属的GPT。微软创始人比尔盖茨称ChatGPT的出现有着重大历史意义&#xff0c;不亚…

(C语言)二分查找 超详细

&#x1f4cc; 博客主页 爆打维c 目录 一、二分查找的原理 1.优点 2.缺陷 3.原理&#xff08;核心思想&#xff09; 4.例题 描述 思路: 一、二分查找的原理 在讲原理之前&#xff0c;先为大家分析一下二分查找的优缺点。 1.优点 如果我们要在数组里面找一个元素的位置…