使用 scoped 后,父组件的样式将不会渗透到子组件中。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <template> <div id="app"> <el-input class="text-box" v-model="text"></el-input> </div> </template> <script> export default { name: 'App', data() { return { text: 'hello' }; } }; </script> <style lang="less" scoped> .text-box { input { width: 166px; text-align: center; } } </style> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <template> <div id="app"> <el-input v-model="text" class="text-box"></el-input> </div> </template> <script> export default { name: 'App', data() { return { text: 'hello' }; } }; </script> <style lang="less" scoped> .text-box { /deep/ input { width: 166px; text-align: center; } } </style> |
1 2 3 4 | <style scoped> .a >>> .b { /* ... */ } </style> //对于scss这类的预处理器需要用上面/deep/的写法,此方法无法正常编译解析 |
1 | .a[data-v-f3f3eg9] .b { /* ... */ } |
官方文档:https://vue-loader.vuejs.org/guide/scoped-css.html#deep-selectors
上一篇:Javascript生成唯一id标识符(GUID,UUID,ID)的方法
支付宝扫一扫打赏
微信扫一扫打赏
共 0 条评论关于"Vue scoped CSS 与深度作用选择器 deep"
最新评论