Complete the code to listen for a right-click event on the button.
<template> <button @click.[1]="handleClick">Right Click Me</button> </template> <script setup> function handleClick() { alert('Right click detected!') } </script>
The .right modifier listens for right mouse button clicks.
Complete the code to listen for a middle mouse button click on the div.
<template> <div @click.[1]="handleMiddleClick">Click me with middle button</div> </template> <script setup> function handleMiddleClick() { console.log('Middle button clicked') } </script>
The .middle modifier listens for middle mouse button clicks.
Fix the error in the code to listen for a left mouse button click on the span.
<template> <span @click.[1]="handleLeftClick">Click me</span> </template> <script setup> function handleLeftClick() { alert('Left click detected') } </script>
The .left modifier listens for left mouse button clicks explicitly.
Fill both blanks to listen for right and middle mouse button clicks on the div.
<template> <div @click.[1]="handleRight" @click.[2]="handleMiddle">Click me</div> </template> <script setup> function handleRight() { console.log('Right click') } function handleMiddle() { console.log('Middle click') } </script>
Use .right for right clicks and .middle for middle clicks.
Fill all three blanks to create a Vue component that listens for left, right, and middle mouse clicks on a button.
<template> <button @click.[1]="onLeft" @click.[2]="onRight" @click.[3]="onMiddle">Click me</button> </template> <script setup> function onLeft() { console.log('Left click') } function onRight() { console.log('Right click') } function onMiddle() { console.log('Middle click') } </script>
Use .left, .right, and .middle modifiers to listen for respective mouse buttons.
