javascript - scoped in vue single file style is invalid, please give me the reason.
仅有的幸福
仅有的幸福 2017-05-19 10:27:37
0
3
1136

a.vue

 

b.vue

 

But when accessing b.vue, the boostrap style is attached. Scoped does not have the effect of isolating the scope?

仅有的幸福
仅有的幸福

reply all (3)
phpcn_u1582

I guess it’s because of @import

First, let’s take a look at the principle of scoped in vue-loader:
https://vue-loader.vuejs.org/...

The page with bootstrap style only means that the bootstrap css has not been processed by vue-loader. Then I searched for the following postcss and @import keywords, and then found the postcss-import plug-in:
https://www. npmjs.com/package…

I think if you use this plug-in, it should be able to solve the problem, but I haven’t tested it, it’s just speculation

    过去多啦不再A梦

    Look for the parent page of b, go up level by level, it must be referenced by that page

      大家讲道理

      Just put it@import '../css/bootstrap.css';去掉;
      换成and it’s ready

        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!