Vue 教程
/ 范围样式
范围样式
作用域样式
为了避免一个组件中的样式影响其他组件中元素的样式,我们在 <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>
运行示例 »