App.vue中设置
<style scoped>
.title{
color: red;
}
</style>
在App的子组件中
<template>
<div class="demo">
<h2 class="title">学生姓名:{{name}}</h2>
<h2>学生性别:{{sex}}</h2>
</div>
</template>
引用title类名,不起作用。因为一旦定义scoped属性,只能在它的模板使用
但是有疑惑?
<template>
<div class="demo title">
<h2 >学生姓名:{{name}}</h2>
<h2>学生性别:{{sex}}</h2>
</div>
</template>
我把title写在div中,字体颜色变为红色了,为什么?