非 Prop 的 Attribute
什么是 非 Prop 的 Attribute 呢?就比如我们的 DOM 元素自带的属性 class
,style
,id
,href
等等。
Attribute 继承
当组件返回单个根节点时,非 prop attribute 将自动添加到根节点的 attribute 中。例如,在 <date-picker>
组件的实例中,就是用我们上节课 TestCom.vue
的代码
<template>
<div class="template-m-wrap">
<test-com
title="这个是组件"
></test-com>
</div>
</template>
<script>
import TestCom from "./TestCom";
export default {
name: "TemplateM",
components: {
TestCom,
},
data() {
return {
};
},
};
</script>
TemplateM.vue
如下:
<template>
<div class="template-m-wrap">
<t