iview中的事件和方法如下: 案例說明: html代碼 <Tree :data="data4" @on-check-change="choiceAll" ref="tree4" show-checkbox multiple></Tree> data(){ data4: [ { title: 'pa ...
iview中的事件和方法如下:
案例說明:
html代碼
<Tree :data="data4" @on-check-change="choiceAll" ref="tree4" show-checkbox multiple></Tree> ------------------------------------------------------------------------------------------- data(){ data4: [ { title: 'parent 1-1', expand: true, children: [ { title: 'leaf 1-1-1', }, { title: 'leaf 1-1-2' } ] }, { title: 'parent 1-2', expand: true, children: [ { title: 'leaf 1-2-1', checked: true }, { title: 'leaf 1-2-1' } ] } ] }, methods:{ choiceAll:function(data){ console.log(data); //當覆選框選中時則會列印出選中的內容 let choicesAll=this.$refs.tree4.getCheckedNodes; //方法的運用 getSelectedNodes也是如此用法 console.log(choicesAll); } } 總結: on-select-change,on-check-change,on-toggle-expand 運用方法是類同而tree方法的運用則需要先添加一個ref