Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 使用<;模板></模板>;组件模板内的标记_Vue.js - Fatal编程技术网

Vue.js 使用<;模板></模板>;组件模板内的标记

Vue.js 使用<;模板></模板>;组件模板内的标记,vue.js,Vue.js,在处理类似于此的组件时 ... props: [ 'fType', 'fName', 'fChoiceValue', ], template: ` <template v-if="fType == ('text' || 'password')"> <input v-bind:type="fType" v-bind:name="fName"> </template> `, 。。。 道具:[ “fType”

在处理类似于此的组件时

...
props: [
    'fType',
    'fName',
    'fChoiceValue',
],
template: `
    <template v-if="fType == ('text' || 'password')">
        <input v-bind:type="fType" v-bind:name="fName">
    </template>
`,
。。。
道具:[
“fType”,
“fName”,
“fChoiceValue”,
],
模板:`
`,

我发现vue不会呈现
标记之间的任何内容。在不使用
代替
的情况下,正确的方法是什么?

Vue将就此向您发出警告

无法将
用作组件根元素,因为它可能包含 多个节点

这就是说,由于您不想包装,并且借用@Phil(您问题中的语法将始终使用
fType
等于
text
)进行计算),因此您可以将输入作为根进行渲染

template: `
  <input v-if="fType == 'text' || fType == 'password'" v-bind:type="fType" v-bind:name="fName">
`,
模板:`
`,

.

不幸的是,vue并没有在控制台中抛出任何错误。几个小时后,我遇到了“文本”和“密码”的问题——我不知道我在想什么;最终使用了lodash indexOf。谢谢。@Dayo在开发时,不要使用Vue的
min
版本。这是生产版本,它不会在控制台中显示警告。@Bert…谢谢提醒。我现在看到所有的警告和错误。