收藏271
分享
阅读24189
更新时间2025-08-22
为了避免一个组件中的样式影响其他组件中元素的样式,我们在 <style> 标签上使用"scoped"属性:
CompOne.vue 中的 <style> 标签被赋予了 scoped 属性:
<template>
<p>This p-tag belongs to 'CompOne.vue'</p>
</template>
<script></script>
<style scoped>
p {
background-color: pink;
width: 150px;
}
</style>
运行示例 »
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.3万人学习
共49课时
77.4万人学习
共29课时
62万人学习
共25课时
39.5万人学习
共43课时
71.2万人学习
共25课时
61.9万人学习
共22课时
23.1万人学习
共28课时
34.1万人学习
共89课时
125.7万人学习