ant-design-vue/components/vc-tree/demo/contextmenu.vue

77 lines
1.9 KiB
Vue
Raw Normal View History

2018-04-12 14:04:55 +00:00
<script>
/* eslint no-console:0 */
2019-01-12 03:33:27 +00:00
import Tree, { TreeNode } from '../index';
import '../assets/index.less';
import './contextmenu.less';
2018-04-12 14:04:55 +00:00
export default {
2019-09-28 12:45:07 +00:00
data() {
2018-04-12 14:04:55 +00:00
return {
selectedKeys: ['0-1', '0-1-1'],
2019-01-12 03:33:27 +00:00
};
2018-04-12 14:04:55 +00:00
},
methods: {
2019-09-28 12:45:07 +00:00
onSelect(selectedKeys) {
2019-01-12 03:33:27 +00:00
this.selectedKeys = selectedKeys;
2018-04-12 14:04:55 +00:00
},
2019-09-28 12:45:07 +00:00
onRightClick(info) {
2019-01-12 03:33:27 +00:00
console.log('right click', info);
this.selectedKeys = [info.node.eventKey];
2018-04-12 14:04:55 +00:00
},
2019-09-28 12:45:07 +00:00
onMouseEnter(info) {
2019-01-12 03:33:27 +00:00
console.log('enter', info);
2018-04-12 14:04:55 +00:00
},
2019-09-28 12:45:07 +00:00
onMouseLeave(info) {
2019-01-12 03:33:27 +00:00
console.log('leave', info);
2018-04-12 14:04:55 +00:00
},
},
2019-09-28 12:45:07 +00:00
render() {
2018-04-12 14:04:55 +00:00
return (
<div>
<h2>right click contextmenu</h2>
<Tree
onRightClick={this.onRightClick}
onSelect={this.onSelect}
selectedKeys={this.selectedKeys}
multiple
defaultExpandAll
showLine
showIcon={false}
>
2019-09-28 12:45:07 +00:00
<TreeNode title="parent 1" key="0-1">
<TreeNode title="parent 1-0" key="0-1-1">
<TreeNode title="leaf0" isLeaf />
<TreeNode title="leaf1" isLeaf />
<TreeNode title="leaf2" isLeaf />
2018-04-12 14:04:55 +00:00
</TreeNode>
2019-09-28 12:45:07 +00:00
<TreeNode title="parent 1-1">
<TreeNode title="leaf" isLeaf />
2018-04-12 14:04:55 +00:00
</TreeNode>
</TreeNode>
</Tree>
<h2>hover popup contextmenu</h2>
<Tree
2019-09-28 12:45:07 +00:00
onMouseenter={this.onMouseEnter}
onMouseleave={this.onMouseLeave}
2018-04-12 14:04:55 +00:00
onSelect={this.onSelect}
2019-09-28 12:45:07 +00:00
multiple
defaultExpandAll
showLine
2018-04-12 14:04:55 +00:00
>
2019-09-28 12:45:07 +00:00
<TreeNode title="parent 1" key="0-1">
<TreeNode title="parent 1-0" key="0-1-1">
<TreeNode title="leaf" isLeaf />
<TreeNode title="leaf" />
2018-04-12 14:04:55 +00:00
</TreeNode>
2019-09-28 12:45:07 +00:00
<TreeNode title="parent 1-1">
<TreeNode title="leaf" />
2018-04-12 14:04:55 +00:00
</TreeNode>
</TreeNode>
</Tree>
</div>
2019-01-12 03:33:27 +00:00
);
2018-04-12 14:04:55 +00:00
},
2019-01-12 03:33:27 +00:00
};
2018-04-12 14:04:55 +00:00
</script>