javascript - iView中 tree 樹控件 的方法調用有錯
問題描述
官網的說明Tree methods
方法名說明參數(shù)getCheckedNodes獲取被勾選的節(jié)點無getSelectedNodes獲取被選中的節(jié)點無自己擼的代碼----------------------------------
<button @click=’getCheckedNodes’>獲取被選中的節(jié)點</button><button @click='getSelectedNodes'>獲取被勾選的節(jié)點</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>
相關文章:
1. Java反射問題:為什么android.os.Message的recycleUnchecked方法不能通過反射獲取到?2. 如何分別在Windows下用Winform項模板+C#,在MacOSX下用Cocos Application項目模板+Objective-C實現(xiàn)一個制作游戲的空的黑窗口?3. html5和Flash對抗是什么情況?4. php如何獲取訪問者路由器的mac地址5. javascript - 在 vue里面用import引入js文件,結果為undefined6. 前端 - node vue webpack項目文件結構7. 小程序怎么加外鏈,語句怎么寫!求救新手,開文檔沒發(fā)現(xiàn)8. python - linux怎么在每天的凌晨2點執(zhí)行一次這個log.py文件9. javascript - vue-resource中如何設置全局的timeout?10. thinkPHP5中獲取數(shù)據(jù)庫數(shù)據(jù)后默認選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙
