JSFiddle - React, Tailwind, and code Playground
by fenivana
HTML
<script src="https://rawgit.com/yyx990803/vue/master/dist/vue.js"></script>
<ns-tree :list="list"><</ns-tree>
JavaScript
var treeOpts = {
name: 'v-tree',
props: ['list'],
template: '<ul>' +
'<li v-for="item in list">{{item.value}}' +
'<v-tree v-if="item.children" :list="item.children"></v-tree>' +
'</li>' +
'</ul>'
};
// registered the tree component with a different name
// e.g. add namespace
// this will cause error
Vue.component('ns-tree', treeOpts);
// this works fine
// Vue.component('ns-tree', Vue.extend(treeOpts));
new Vue({
el: 'body',
data: {
list: [
{ value: 'foo' },
{ value: 'bar', children: [
{ value: 'baz' }
] }
]
}
});