tongsiying

阅读|运动|自律

0%

Vue开发积累

Vue 开发积累

001:scoped 关键字的作用

xx.vue 组件中,我们可能会遇到带 scoped 关键字的样式。比如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

上方的scoped表示的是作用域化,样式只对当前子组件生效。

赞赏一下吧~