【问题标题】:Receiving "failed to load component"收到“未能加载组件”
【发布时间】:2015-12-14 14:20:17
【问题描述】:

我正在尝试使用 Vue.js 将一些内容加载到组件中。我正在尝试使用 :is 属性来做到这一点。我不断收到“[Vue 警告]:无法解析组件:面试”

<todo-tabs :list="items"></todo-tabs>

<template id="interview-slot">
 //Interview Slot Content
</template>

<template id="membership-slot">
 //Interview Slot Content
</template>

<script>
Vue.component('todo-tabs', {
        template: '#todo-tabs',
        props: ['list'],
        data: function(){
            return {
                currentView: 'interview',
                components:{
                    interview:{
                        template: '#interview-slot'
                    },
                    membership:{
                        template: '#membership-slot'
                    }
                }
            }
        }
});


var vm = new Vue({
el: "#todo",
data: {
items : [
            {id: 'interview', name: 'interview', complete: true, body: 'something1', step_content: 'SOME',current: true  },
            {id: 'membership', name: 'membership', complete: true, body: 'something2', step_content: 'SOME' },
            {id: 'profile', name: 'profile', complete: false, body: 'something3', step_content: 'SOME'  },
            {id: 'handoff', name: 'handoff', complete: false, body: 'something4', step_content: 'SOME'}
        ]
    }
});
</script>

如果可能的话,我真的不想将我的 html 放入 json 中,因为它包含很多表单元素。

提前感谢您的任何帮助

【问题讨论】:

  • 我看到的唯一注册组件是 todo-tabs。面试不是。

标签: javascript vue.js


【解决方案1】:

在这部分代码中:

<template id="interview-slot">
  //Interview Slot Content
</template

您在&lt;/template 之后缺少结束&gt;

【讨论】:

  • 感谢@foxdonut,这是创建问题时的错字。代码已正确关闭,但仍收到错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-27
  • 1970-01-01
  • 2015-03-01
  • 2020-05-21
  • 1970-01-01
  • 2020-03-27
相关资源
最近更新 更多