Vue 关于scoped范围限制后无法选中某些el-input组件记录

今天在写个小的DR网页的时候,碰到一个问题郁闷许久,因为不想自己写的component css 污染全局,所以想在 css 中带上scoped去限制范围,但是这样导致一直无法选中el-input中的真正的textarea组件,在做了一些research以后发现可以使用深度作用选择器来选中自己想要的组件。无法选中的根本原因是因为加了scoped以后,在el-input组件的div上加了个不重复的id,导致我想选中textarea最终css选择器必须是这样的:.container .form .el-form-item .textarea[data-v-542f2b52] textarea, 但是我在代码中正常写.container .form .el-form-item .textarea textarea 只会变成.container .form .el-form-item .textarea textarea[data-v-542f2b52]这样,所以一直没办法选中,最终使用了深度作用选择器以后是这样写的:.container .form .el-form-item .textarea /deep/ textarea,这个最终在浏览器显示的选择器就会是我们想要的.container .form .el-form-item .textarea[data-v-542f2b52] textarea这个了。在这里插入图片描述最后附上查询到知识点的详细链接。scoped父组件覆盖子组件css

猜你喜欢

转载自blog.csdn.net/github_39436025/article/details/84641740