I need to get the reference of the selected item in TreeView
of iView
, already tried with getSelectedNodes()
but it seems the method is not being used correctly, and the documentation does not help much ...
var Main = {
data () {
return {
data1: [
{
title: 'parent 1',
expand: false,
children: [
{
title: 'parent 1-1',
expand: false,
children: [
{
title: 'leaf 1-1-1'
},
{
title: 'leaf 1-1-2'
}
]
},
{
title: 'parent 1-2',
expand: false,
children: [
{
title: 'leaf 1-2-1'
},
{
title: 'leaf 1-2-1'
}
]
}
]
}
]
}
},
methods : {
getSelectedNodes (el) {
console.log(el);
}
}
}
var Component = Vue.extend(Main)
new Component().$mount('#app')
@import url("//unpkg.com/iview/dist/styles/iview.css");
#app{padding: 32px;}
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/iview/dist/iview.min.js"></script>
<div id="app">
<tree :data="data1"></tree>
</div>
If possible, I would also like to know how I can instantiate an event of click
for each item.