javascript - In the vue.js component development model, how to make the style only apply to this component and its subcomponents.
怪我咯
怪我咯 2017-05-18 10:51:18
0
1
934

If scoped is used, the style can only affect the current component but not its sub-components. Sometimes due to design problems, there are a lot of styles shared between different sub-components. I want to ask the master if the style can only be applied to This component and its subcomponents.

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
漂亮男人

Don’t use scoped and take control of the css namespace yourself

You can name each component with a specific and unique class, and the CSS of the component is within the scope of this naming.

For example, header is a subcomponent of index

    .header-comp{
        h2{
            
        }
        .title{
        
        }
    }
    .index-view{
        .container{
        
        }
    }

Final rendering

    <p class="index-view">
        <p class="header-comp"></p>
    </p>
    .index-view{}
    .index-view xxx{}
    .header-comp{}
    .hader-comp .xxxx{}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!