How to bind multiple clicks with different modifiers in vue?
巴扎黑
巴扎黑 2017-05-19 10:44:42
0
2
557
<input v-on:click.ctrl="SelectedMultiple(item.id)" v-on:click="Selected(item.id)" />

如上  我想实现的是 按住ctrl的时候多选 
但是在触发SelectedMultiple之后会再次触发Selected事件
这个该如何解决呢?
巴扎黑
巴扎黑

reply all(2)
小葫芦

Each v-on will have an independent handler. When the event is triggered, it is placed in an array and executed sequentially.
They will not affect each other. @click.ctrl cannot prevent the execution of @click.
So it can only be executed in @click judges $event to filter out events where ctrl is pressed

<input @click.ctrl="SelectedMultiple(item.id)" 
@click="!$event.ctrlKey && Selected(item.id)" />
黄舟

There should be a keyboard event

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!