说明
就是说在父组件中给子组件传递值,但是子组件不在prop中接受
案例
- 父组件中
<template>
<div>
<child oldMsg="hello" oldMsg1="hello1" />
</div>
</template>
- 子组件中只有一个div时候
<template>
<!-- 自动获取全部属性 -->
<div>child</div>
</template>
开启inheritAttrs: false,会禁止继承
- 子组件中多个div时候
<template>
<!-- 获取全部属性 -->
<div v-bind="$attrs">child</div>
<!-- 获取指定属性hello并命名为newMsg -->
<div :newMsg="$attrs.oldMsg">child</div>
</template>