vue 递归组件之多级联动

多级联动的基本就是运用递归组件
其中要注意这么几点:
(在我的代码中需要这么注意)
【用isflag来判断是否需要渲染v-if -----是否渲染v-show-------是否展开注意联动组件的一致性:比如v-bind所绑定的属性的一致性!!!!!!!( :list=‘item’ )注意填写数据的时候的分级和嵌套!!!

Vue.component('list-tree',{     
 template : '#demo',   
    props : ['list'],    
      computed: {      
        isflag(){       
           return this.list.cList && this.list.cList.length   
                }   
                   },    
        methods: {    
            toggle(isflag){      
                 this.open = !this.open    
                     }   
                        },   
         data() {    
             return {       
                open : false    
                    }   
                       },  
                         })   


    var vm = new Vue({      el: '#app',      data() {        return {
          list:。。。。。。}
          }
          })

你可能感兴趣的:(vue)