javascript - iView中 tree 树控件 的方法调用有错
本文介绍了javascript - iView中 tree 树控件 的方法调用有错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
官网的说明
Tree methods
方法名 | 说明 | 参数 |
getCheckedNodes | 获取被勾选的节点 | 无 |
getSelectedNodes | 获取被选中的节点 | 无 |
自己撸的代码----------------------------------
<button @click='getCheckedNodes'>获取被选中的节点</button>
<button @click="getSelectedNodes">获取被勾选的节点</button>
自己撸的代码---------------------------
getCheckedNodes(){
console.log(this.$refs.Tree.getCheckedNodes());
},
getSelectedNodes(){
console.log(this.$refs.tree.getSelectedNodes);
}
报错
App.vue?2573:105 Uncaught TypeError: Cannot read property 'getCheckedNodes' of undefined
at VueComponent.getCheckedNodes (eval at <anonymous> (app.js:967), <anonymous>:92:40)
at boundFn (eval at <anonymous> (app.js:723), <anonymous>:125:14)
at HTMLButtonElement.invoker (eval at <anonymous> (app.js:723), <anonymous>:1659:18)
解决方案
Tree组件调用上面要写上ref
<Tree :data="baseData" show-checkbox ref="tree"></Tree>
这篇关于javascript - iView中 tree 树控件 的方法调用有错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文