您的位置:首頁技術文章
文章詳情頁

javascript - iView中 tree 樹控件 的方法調用有錯

瀏覽:63日期:2023-03-20 10:24:18

問題描述

官網的說明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>

標簽: JavaScript
相關文章:
国产综合久久一区二区三区