vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

232 - 按键修饰符

Open kalu5 opened this issue 2 years ago • 0 comments

// 你的答案
<template>
  <!-- Add key modifiers made this will fire even if Alt or Shift is also pressed -->
<button @click.ctrl="onClick1">A</button>

<!-- Add key modifiers made this will only fire when Shift and no other keys are pressed -->
<button @click.shift.exact="onCtrlClick">A</button>

<!-- Add key modifiers made this will only fire when no system modifiers are pressed -->
<button @click.exact="onClick2">A</button>
</template>

<script setup>
  function onClick1(){
    console.log('onClick1')
  }
  function onCtrlClick(){
    console.log('onCtrlClick')
  }
  function onClick2(){
    console.log('onClick2')
  }
</script>

kalu5 avatar Sep 16 '22 10:09 kalu5