2.6.10
https://github.com/tbutcaru/v-issue-multiple-dynamic-slot-names
npm install
npm run serve
多个动态插槽名称应按预期工作。
引发以下错误:
Invalid dynamic argument expression: attribute names cannot contain spaces, quotes, <, >, / or =.#[headerslot]>Header slot</template>
Default slot
<template #[footerslot]
如果将其中一个动态插槽名称设置为静态(与哪个无关),则该应用程序正在运行。
node_modules/vue-template-compiler/build.js
attrs.forEach(function (attr) {
)添加了以下警告:warn$1('--------------->> ' + attr.name);
#[headerslot]
#[headerslot]>Header slot</template>
Default slot
<template #[footerslot]
因此,当存在多个动态插槽名称时,似乎编译器不知道如何仅提取属性。
仅当提供参数时,速记才可用。 尝试使用:
<template v-slot:[dynamicSlotName]>
...
</template>
仅当提供参数时,速记才可用。 尝试使用:
<template v-slot:[dynamicSlotName]> ... </template>
我在创建问题之前已经尝试过,结果是一样的
嗨,大家好!
有什么新消息吗? 我仍然在2.6.11的问题这里重现
经过多次尝试,我找到了使多个动态广告位起作用的方法。 当我将键添加到动态插槽模板的根元素时,它就起作用了:
这不起作用:在此处复制
<template #[slot1]>
<p>slot test</p>
</template>
<template #[slot2]>
<p>slot test2</p>
</template>
// got "Invalid dynamic argument expression: attribute names cannot contain spaces, quotes, <, >, / or ="
这项工作:在这里复制
<template #[slot1]>
<p key="1">slot test</p>
</template>
<template #[slot2]>
<p key="2">slot test2</p>
</template>
// work fine
为什么我需要添加密钥才能使其正常工作? 我错过了什么。
@ davis90的解决方案对我
为什么这些错误会引起误导。 谢谢,尽管您的解决方案有效
最有用的评论
经过多次尝试,我找到了使多个动态广告位起作用的方法。 当我将键添加到动态插槽模板的根元素时,它就起作用了:
这不起作用:在此处复制
这项工作:在这里复制
为什么我需要添加密钥才能使其正常工作? 我错过了什么。