在处理类似于这样的组件时。
...
props: [
'fType',
'fName',
'fChoiceValue',
],
template: `
<template v-if="fType == ('text' || 'password')">
<input v-bind:type="fType" v-bind:name="fName">
</template>
`,我发现vue不会在<template>标记之间呈现任何内容。在不使用<span></span>代替<template></template>的情况下,如何才能做到这一点呢?
发布于 2017-05-11 23:51:42
会警告你的。
不能使用
<template>作为组件根元素,因为它可能包含多个节点。
尽管如此,由于您不想包装,并借用@Phil (您的问题中的语法总是以fType等于text计算),所以您只需将输入作为根。
template: `
<input v-if="fType == 'text' || fType == 'password'" v-bind:type="fType" v-bind:name="fName">
`,示例。
https://stackoverflow.com/questions/43927277
复制相似问题