Web/16-前端工程化/Vue开发积累.md
2021-07-29 11:08:52 +08:00

32 lines
490 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Vue 开发积累
### 001scoped 关键字的作用
`xx.vue` 组件中,我们可能会遇到带 `scoped` 关键字的样式。比如:
```html
<!-- 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`表示的是**作用域化**,样式只对当前子组件生效。