2016-04-21 84 views
5

基于Vuejs文档示例,我试图做一个简单的treeview组件,我可以在其中显示没有任何联系的帐户图表(不添加任何拖放操作...非常简单)。Vueify上的Vuejs递归组件

我在FiddleJs上做了一个例子,但那里工作正常我的例子...我不知道为什么在我的应用程序,我不能让它的作品!我不知道这是否是一些Vueify问题...可能是你可以帮助我!

有我的代码:

OzChartTree.vue

<template> 

    <ul v-if="model.length"> 
     <li v-for="m in model" :class="{ 'is-group': m.children }"> 
      {{ m.name }} 
      <ul v-if="m.accounts"> 
       <li v-for="a in m.accounts"> 
        {{ a.name }} 
       </li> 
      </ul> 
      <oz-tree :model="m"></oz-tree> 
     </li> 
    </ul> 

</template> 

<script type="text/babel"> 

    import OzChartTree from './OzChartTree.vue' 

    export default { 

     components: { 
      OzTree: OzChartTree 
     }, 

     props: { 
      model: Array, 
     } 

    } 

</script> 

当我第一时间致电树视图组件

<oz-chart-tree :model="chart"></oz-chart-tree> 

问题是,当我打电话递归地在ja .vue文件上的组件。

由于这是上面我得到了以下错误:

app.js:23536 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

但被正确注册为OzTree!我无法理解!

有人有什么想法吗?

回答

12
<script type="text/babel"> 

    import OzChartTree from './OzChartTree.vue' 

    export default { 
     name: 'oz-tree-chart', // this is what the Warning is talking about. 

     components: { 
      OzTree: OzChartTree 
     }, 

     props: { 
      model: Array, 
     } 

    } 

</script> 
+2

递归组件的文档:http://vuejs.org/guide/components.html#Recursive-Component – Jeff