1

I have two components that they have a childs in router like this:

{
        path: '/admin',
        component: AdminMain,
        children:[
            {
                path: '/admin',
                component: AdminHome,
                name: 'AdminHome'
            }
        ]
 },
 {
        path: '/',
        component: Home,
        children:[
            {
                path: '/',
                component: Index,
                name: 'Index'
            }
        ]
 }

I want to do two separate layout for these components so their childs inherit parents css. It is possible ? At the moment I load css file in every component with scoped because my css file conflict with vuetify css.

2
  • I had an answer for a similar question in stackoverflow.com/a/49654061/5599288 . Maybe it will be useful to you. Commented Jun 2, 2018 at 16:11
  • @JacobGoh Unfortunately in my case it not working. Imported code in SCSS is out of te selector body as new <style> tag Commented Jun 3, 2018 at 8:07

2 Answers 2

2

DOM content created with v-html are not affected by scoped styles, but you can still style them using deep selectors.

This wording in the Deep Selectors page of the Vue docs sounds like it contradicts itself. But it's saying, for instance, if you want to scope-style a 'p' element and have those changes show up in a v-html, your css should look like this.

>>> p {
/* some css */
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can you deep selectors to affect css of child component

AdminMain.vue (parent component)

<style scoped>
.a >>> .b { /* ... */ }
</style>

will be translate to .a[data-v-f3f3eg9] .b { /* ... */ }

then .b will effect children component (AdminHome.vue)

2 Comments

Ok, but i use bootstrap. In this case i must add ">>>" operator in the whole file?
With 3rd party css, you can import it in main.js or root component.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.