So, I've read here that in Vue.js, you can use /deep/
or >>>
in a selector in order to create style rules that apply to elements inside of child components. However, attempting to use this in my styles, whether in SCSS or in plain old CSS, doesn't work. Instead, they are sent to the browser verbatim, and therefore have no effect. For example:
home.vue:
<style lang="css" scoped>
.autocomplete >>> .autocomplete-input
{
// ...
}
</style>
generated css:
<style type="text/css">
.autocomplete >>> .autocomplete-input[data-v-2bda0c9a]
{
//...
}
</style>
what I want:
<style type="text/css">
.autocomplete[data-v-2bda0c9a] .autocomplete-input
{
//...
}
</style>
My webpack configuration pertaining to vue-loader
looks like this:
// ...
{
test: /\.vue$/,
loader: "vue-loader",
options: {
loaders: {
scss: "vue-style-loader!css-loader!sass-loader"
}
}
}
// ...
So my question is, how do I get this >>>
operator to work?
I've already found this answer, but I'm doing exactly that and it doesn't work...
scoped
modifier. – Harlotscoped
attribute and the>>>
operator does indeed make the style rule work, but it's less than optimal. As Roy J pointed out, thisscoped
attribute has nothing to do with the W3C. – Pilch<style scoped>
,>>>
should work (.autocomplete >>> .autocomplete-input
) and with<style lang="scss" scoped>
,/deep/
should work (.autocomplete /deep/ .autocomplete-input
) (tested with nuxt 1.4 / vue 2.5) – Sternson