标题:
Vue 3.0多个根节点上的 Attribute 继承
[打印本页]
作者:
vicky.yu
时间:
2023-8-10 09:18
标题:
Vue 3.0多个根节点上的 Attribute 继承
与单个根节点组件不同,具有多个根节点的组件不具有自动 attribute 回退行为。如果未显式绑定 $attrs,将发出运行时警告。
<custom-layout id="custom-layout" @click="changeValue"></custom-layout>
// 这将发出警告
app.component('custom-layout', {
template: `
<header>...</header>
<main>...</main>
<footer>...</footer>
`
})
// 没有警告,$attrs被传递到<main>元素
app.component('custom-layout', {
template: `
<header>...</header>
<main v-bind="$attrs">...</main>
<footer>...</footer>
`
})
欢迎光临 赛捷软件论坛 (http://sagesoft.cn/bbs/)
Powered by Discuz! 7.2