iview/examples/routers/tree.vue

69 lines
2.5 KiB
Vue
Raw Permalink Normal View History

<template>
2020-09-03 15:53:31 +08:00
<Tree :data="data4" show-checkbox multiple @on-contextmenu="handleContextMenu">
<template slot="contextMenu">
<DropdownItem @click.native="handleContextMenuEdit">编辑</DropdownItem>
<DropdownItem @click.native="handleContextMenuDelete" style="color: #ed4014">删除</DropdownItem>
</template>
</Tree>
</template>
<script>
export default {
2017-03-03 10:35:38 +08:00
data () {
2017-02-07 11:34:00 +08:00
return {
2019-10-09 16:41:00 +08:00
data4: [
2017-03-24 20:50:13 +08:00
{
2019-10-09 16:41:00 +08:00
title: 'parent 1',
expand: true,
2020-09-03 15:53:31 +08:00
selected: true,
contextmenu: true,
2019-10-09 16:41:00 +08:00
children: [
{
title: 'parent 1-1',
expand: true,
2020-09-03 15:53:31 +08:00
disabled: true,
contextmenu: true,
2019-10-09 16:41:00 +08:00
children: [
{
title: 'leaf 1-1-1',
disabled: true
},
{
title: 'leaf 1-1-2'
}
]
},
{
title: 'parent 1-2',
expand: true,
2020-09-03 15:53:31 +08:00
contextmenu: true,
2019-10-09 16:41:00 +08:00
children: [
{
title: 'leaf 1-2-1',
2020-09-03 15:53:31 +08:00
checked: true
2019-10-09 16:41:00 +08:00
},
{
2020-09-03 15:53:31 +08:00
title: 'leaf 1-2-1',
contextmenu: true,
2019-10-09 16:41:00 +08:00
}
]
}
]
2019-08-29 11:42:30 +08:00
}
2020-09-03 15:53:31 +08:00
],
contextTitle: 0
2019-10-09 16:41:00 +08:00
}
2019-08-29 11:42:30 +08:00
},
methods: {
2020-09-03 15:53:31 +08:00
handleContextMenu (data) {
this.contextTitle = data.title;
},
handleContextMenuEdit () {
this.$Message.info('Click edit of line' + this.contextTitle);
},
handleContextMenuDelete () {
this.$Message.info('Click delete of line' + this.contextTitle);
2017-10-23 11:55:35 +08:00
}
2017-02-07 11:34:00 +08:00
}
2019-10-09 16:41:00 +08:00
}
2017-10-25 22:34:58 +08:00
</script>