fengyuanchen / photo-editor

A simple photo editing application.
https://fengyuanchen.github.io/photo-editor
MIT License
936 stars 238 forks source link

为什么nav的事件会触发多次 #22

Closed witwave closed 6 years ago

witwave commented 6 years ago
<nav class="nav" @click="click"  >
<button type="button" class="nav__button nav__button--success" data-action="" title="测试" ><span class="fa fa-check"></span></button>
</nav
   click({ target }) {
      const action = target.getAttribute("data-action") || target.parentElement.getAttribute("data-action");
      console.log('traget',action);
      if (action) {
        this.$emit("change", action);
      }
    }

点击一下,会触发多次,有时一次,有时二次...

fengyuanchen commented 6 years ago

点击 <label> 元素会多触发一次 click 事件。

witwave commented 6 years ago

但这样会有问题,我点了crop,然后再取消,然后再点crop,再点取消,同时会直接调了remove。请问下,怎么只触发一次事件? @fengyuanchen

witwave commented 6 years ago

非常感谢你的开源项目,帮我节省了不少时间。

使用的过程中,还有一个小问,这个触发多次。这样会导致一个问题,可能我上们没有说太清楚,

就是在不断的点 crop icon的时候和取消的时候,有时会触发 remove, 还有时会触发 upload.

我加了日志, 会触发多次或者一次,没有想明白为什么。

而且这样会操作图的过程度中, 我剪切的不满意的,取消,再剪切,再取消, 多试几次,有时就直接跳到上传界面了, 又得重新选一次图,

不是很方便用户使用。

还请帮忙看看

在 2018年6月27日,下午9:39,Fengyuan Chen notifications@github.com<mailto:notifications@github.com> 写道:

Closed #22https://github.com/fengyuanchen/photo-editor/issues/22.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/fengyuanchen/photo-editor/issues/22#event-1703924379, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AK6JWO1_UL1CHaFTSE39OeghtuPGEucTks5uA4sZgaJpZM4U5sll.