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

76 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 {
data () {
return {
selectedKeys: ['0-1', '0-1-1'],
2019-01-12 03:33:27 +00:00
};
2018-04-12 14:04:55 +00:00
},
methods: {
onSelect (selectedKeys) {
2019-01-12 03:33:27 +00:00
this.selectedKeys = selectedKeys;
2018-04-12 14:04:55 +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
},
onMouseEnter (info) {
2019-01-12 03:33:27 +00:00
console.log('enter', info);
2018-04-12 14:04:55 +00:00
},
onMouseLeave (info) {
2019-01-12 03:33:27 +00:00
console.log('leave', info);
2018-04-12 14:04:55 +00:00
},
},
render () {
return (
<div>
<h2>right click contextmenu</h2>
<Tree
onRightClick={this.onRightClick}
onSelect={this.onSelect}
selectedKeys={this.selectedKeys}
multiple
defaultExpandAll
showLine
showIcon={false}
>
<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 />
</TreeNode>
<TreeNode title='parent 1-1'>
<TreeNode title='leaf' isLeaf />
</TreeNode>
</TreeNode>
</Tree>
<h2>hover popup contextmenu</h2>
<Tree
onMouseenter={this.onMouseEnter} onMouseleave={this.onMouseLeave}
onSelect={this.onSelect}
multiple defaultExpandAll showLine
>
<TreeNode title='parent 1' key='0-1'>
<TreeNode title='parent 1-0' key='0-1-1'>
<TreeNode title='leaf' isLeaf />
<TreeNode title='leaf' />
</TreeNode>
<TreeNode title='parent 1-1'>
<TreeNode title='leaf' />
</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>