返回列表

vue小坑记录一则

默认分类 2017/03/22 00:46

代码如下:

<launchtree :options.sync="treeOptions" :node.sync="treeNodes" :show="show" v-if="treeNodes && treeNodes.length > 0"></launchtree>

lanchtree 中调用了

<v-tree :node-module.sync="node" :options.sync="options"></v-tree>

v-tree 内部代码如下

['<div class="list-tree-item" v-for="item in nodeModule">',
      '<div class="list-tree-title" @click="show(item.id)">',
        '<span class="list-tree-icon" @click.stop.prevent="switchFloder(item)"><span v-if="item.isShow"><i class="icon-expand"></i></span><span v-else><i class="icon-collapse"></i></span></span>',
        '<a class="list-tree-name {{classNameShow(item.id)}}" v-link="item.action||\'\'">{{item.name}}</a>',
      '</div>',
      '<div class="list-tree-children" v-if="item.children && item.children.length>0 && item.isShow">',
        '<div class="list-tree-item" v-for="child in item.children">',
          '<div class="list-tree-title" @click="showChild(child.id)">{{child.id}}</div>',
        '</div>',
      '</div>',
    '</div>'
  ].join(''),

问题描述:

当外部传入的treeNodes中的子项中isShow未预先赋值时后面的v-if="item.isShow"根本就不会生效