iview中tree的事件運用


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  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM