美文网首页
vue中style scope深度访问新方式(::v-deep)

vue中style scope深度访问新方式(::v-deep)

作者: 缺月楼 | 来源:发表于2020-07-09 10:06 被阅读0次

vue中style scope深度访问新方式(::v-deep)
如果vue的style使用的是css,那么则

<style lang="css" scoped>
.a >>> .b { 
   /* ... */ 
}
</style>

但是像scss等预处理器却无法解析>>>,所以我们使用下面的方式.

<style lang="scss" scoped>
.a{
   /deep/ .b { 
      /* ... */ 
   }
} 
</style>

但是有些开发者反应,在vue-cli3编译时,deep的方式会报错或者警告。
此时我们可以使用第三种方式
3、::v-deep
切记必须是双冒号

<style lang="scss" scoped>
.a{
   ::v-deep .b { 
      /* ... */ 
   }
} 
</style>

相关文章

网友评论

      本文标题:vue中style scope深度访问新方式(::v-deep)

      本文链接:https://www.haomeiwen.com/subject/uuljcktx.html