Skip to content

Commit

Permalink
fix(tree): 解决 checkbox 上点击会触发2次 click 的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TabSpace committed Mar 18, 2022
1 parent 56102f1 commit 88eec17
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/tree/tree-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default mixins(getConfigReceiverMixins<Vue, TreeConfig>('tree'), keepAnim
data() {
return {
data: null,
clicked: false,
};
},
methods: {
Expand Down Expand Up @@ -280,6 +281,14 @@ export default mixins(getConfigReceiverMixins<Vue, TreeConfig>('tree'), keepAnim
return itemNodes;
},
handleClick(evt: MouseEvent) {
// checkbox 上也有 emit click 事件
// 用这个逻辑避免重复的 click 事件被触发
if (this.clicked) return;
this.clicked = true;
setTimeout(() => {
this.clicked = false;
});

const { node } = this;
const state: TypeEventState = {
mouseEvent: evt,
Expand Down

0 comments on commit 88eec17

Please sign in to comment.