javascript - iView中 tree 樹控件 的方法調(diào)用有錯
問題描述
官網(wǎng)的說明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組件調(diào)用上面要寫上ref
<Tree :data='baseData' show-checkbox ref='tree'></Tree>
相關(guān)文章:
1. android - 分享到微信,如何快速轉(zhuǎn)換成字節(jié)數(shù)組2. javascript - 能否讓vue-cli的express修改express重啟服務(wù)3. 解決Android webview設(shè)置cookie和cookie丟失的問題4. angular.js - Beego 與 AngularJS的模板格式?jīng)_突,該怎么解決?5. javascript - vue2.0中,$refs對象為什么用駝峰的方式獲取不到屬性?6. node.js - npm一直提示proxy有問題7. html5 - 有人做過防微信app界面的H5 demo嗎?8. javascript - 有沒有iOS微信中可以在背景播放視頻的方法?9. 最新版本的微信web開發(fā)者工具必須要APPID,會提供測試號,但是像你一樣tabBar配置的話不會顯示首頁與日志,難道我要下載跟你一樣的版本?10. Navicat for mysql 中以json格式儲存的數(shù)據(jù)存在大量反斜杠,如何去除?
