Vue使用@import 引入样式文件全局污染、使用scoped失效问题

scoped
在组件中的style使用@import方式引入外部css,发现引入的css会污染到其他地方。即所谓的样式全局污染。不管加不加scoped都一样。

<style lang="scss" scoped>
    @import url("/style/index.scss") 
<style>

上面这种情况即时加入了scoped也无效,样式一样会污染到其他地方。

正确写法:

<style lang="scss"  src="/style/index.scss"  scoped><style>

相关推荐

  1. 如何引入全局样式文件

    2023-12-05 18:30:09       23 阅读
  2. vue html里面使用全局引入的scss变量

    2023-12-05 18:30:09       44 阅读
  3. VUE---组件的样式冲突scoped

    2023-12-05 18:30:09       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-05 18:30:09       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-05 18:30:09       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-05 18:30:09       87 阅读
  4. Python语言-面向对象

    2023-12-05 18:30:09       96 阅读

热门阅读

  1. 【Python】pptx文件转pdf

    2023-12-05 18:30:09       59 阅读
  2. Hive -- 基本概念

    2023-12-05 18:30:09       52 阅读
  3. 将Windows中的Anaconda虚拟环境迁移到Linux系统

    2023-12-05 18:30:09       56 阅读