vue.js - Difference between scoped CSS and "scope" by adding a parent class -
when building app using vue, vue-loader , official boilerplate noticed scoped
css used limit css current component. don't see point in this. have "scoped" css defining inside wrapper class when have felt need it.
for example in sass:
.some-module { h1, h2 { font-weight: normal; } ul { list-style-type: none; padding: 0; } li { display: inline-block; margin: 0 10px; } { color: #42b983; } }
so gain using scoped css instead? or merely method achieve same thing?
if add css in global file can import , when doing scoped css connect styling respective component only.
please refer https://vue-loader.vuejs.org/en/features/scoped-css.html more info
scoped css
when tag has scoped attribute, css apply elements of current component only. similar style encapsulation found in shadow dom. comes caveats, doesn't require polyfills. achieved using postcss transform following:
<style scoped> .example { color: red; } </style> <template> <div class="example">hi</div> </template>
into following:
<style> .example[data-v-f3f3eg9] { color: red; } </style> <template> <div class="example" data-v-f3f3eg9>hi</div> </template>
Comments
Post a Comment