App.vue
----------------------------------------
<template >
<div id="app">
<h2>Hello World</h2>
<HelloWorld />
</div>
</template>
<script>
import HelloWorld from "./HelloWorld.vue";
export default {
components: {
HelloWorld
}
}
</script>
<style scoped>
h2{
color: red;
}
</style>
HelloWorld.vue
<template >
<div id="app">
<h2>Hello World</h2>
<HelloWorld />
</div>
</template>
<script>
import HelloWorld from "./HelloWorld.vue";
export default {
components: {
HelloWorld
}
}
</script>
<style scoped>
h2{
color: red;
}
</style>
# 如果 style 加上了scoped 属性 即标识只对本组件生效
标签:default,vue,作用域,h2,样式,export,HelloWorld,009
From: https://www.cnblogs.com/bengguo/p/18462176