说明
当一个父组件定义了style之后,子组件的相关style也会受到影响,这时可以通过添加scope属性解决。
代码
<!--将h1标签定义为背景色为gree,这时,子页面的h1标签也会受到影响-->
<style>
h1 {background-color: green}
</style>
- 解决:
<style scoped>
h1 {background-color: green}
</style>
说明
当一个父组件定义了style之后,子组件的相关style也会受到影响,这时可以通过添加scope属性解决。
代码
<!--将h1标签定义为背景色为gree,这时,子页面的h1标签也会受到影响-->
<style>
h1 {background-color: green}
</style>
<style scoped>
h1 {background-color: green}
</style>