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 undefinedat 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)
問題解答
回答1:Tree組件調用上面要寫上ref
<Tree :data='baseData' show-checkbox ref='tree'></Tree>
相關文章:
