使用@import引入外部css,作用域是全局的

<template>

</template>

<script>
    export default {
        name: "user"
    };
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
@import "../static/css/user.css";
.user-content{
  background-color: #3982e5;
}
</style>

import并不是引入代码到<style></style>里面,而是发起新的请求获得样式资源,并且没有加scoped

<style scoped>
@import "../static/css/user.css";
</style>

我们只需把@import改成<style src=""></style>引入外部样式,就可以解决样式是全局的问题

<style scoped src="../static/css/user.css">
<style scoped>
.user-content{
  background-color: #3982e5;
}
</style>

 

相关文章:

  • 2022-12-23
  • 2022-02-26
  • 2021-04-29
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
猜你喜欢
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2021-09-15
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案