search

Home  >  Q&A  >  body text

css - How come the styles referenced locally in vue become global?

1.How can the local styles referenced in vue also take effect on other pages? After the router switches the page, it loads the style of the changed page

代言代言2744 days ago1796

reply all(4)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-07-06 10:37:40

    Partial styles can only be applied locally. If you need to use them globally, you can put the public class into app.vue

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-07-06 10:37:40

    In vue, there is the general component app.vue. In this file, the commands you want to promote to the global level can be seen in other operating components. This is the advantage of the declarative framework of vue. In a main The methods or styles defined in the component can be bound to other components

    reply
    0
  • ringa_lee

    ringa_lee2017-07-06 10:37:40

    It just writes the css in a local file, which does not mean that the css only acts locally. If you want it to work only within the component, you can add scoped

    <style scoped>
    /*css code*/
    </style>

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-07-06 10:37:40

    Two ways

    • Control the scope of the tag selector yourself

    • Add scoped to style in the component template.

    reply
    0
  • Cancelreply