运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <title>Right Mouse Button Event</title> <style> #app { border: black dashed 1px; width: 200px; padding: 20px; } #app > div { width: 160px; padding: 20px; cursor: default; font-weight: bold; } </style> </head> <body> <h1>Example</h1> <p>The default drop-down menu is prevented when we right click the DIV element.</p> <div id="app"> <div v-on:click.right.prevent="changeColor" v-bind:style="{ backgroundColor:'hsl('+bgColor+',80%,80%)' }"> <p>Press right mouse button here.</p> </div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { bgColor : 0 } }, methods: { changeColor() { this.bgColor+=50; } } }) app.mount('#app') </script> </body> </html>