We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关键词:事件修饰符
在 Vue 中,事件修饰符是一些由点 (.) 开头的特殊后缀,用于指示 Vue 对 DOM 事件进行某种特殊处理。Vue 提供了一系列的默认事件修饰符来帮助开发者更方便地处理一些常见的 DOM 事件行为。
下面是 Vue 3 中提供的一些默认事件修饰符:
.stop
event.stopPropagation()
.prevent
event.preventDefault()
.capture
.self
.once
.passive
{ passive: true }
preventDefault()
这些修饰符可以单独使用,也可以组合使用。以下是一些示例:
<!-- 阻止点击事件冒泡 --> <button @click.stop="doThis">Stop Propagation</button> <!-- 提交事件不再重载页面 --> <form @submit.prevent="onSubmit">Prevent Default</form> <!-- 修饰符链 --> <a @click.stop.prevent="doThat">Stop Propagation and Prevent Default</a> <!-- 只在 @click.self 表达式中的元素本身(而非子元素)触发时调用 doThat --> <div @click.self="doThat">Only Trigger on Self</div> <!-- 点击事件将只触发一次 --> <button @click.once="doOnce">Trigger Once</button>
使用这些事件修饰符可以使你的事件处理逻辑更简洁和直观,同时也能够实现一些复杂的事件处理方式。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
关键词:事件修饰符
在 Vue 中,事件修饰符是一些由点 (.) 开头的特殊后缀,用于指示 Vue 对 DOM 事件进行某种特殊处理。Vue 提供了一系列的默认事件修饰符来帮助开发者更方便地处理一些常见的 DOM 事件行为。
下面是 Vue 3 中提供的一些默认事件修饰符:
.stop
event.stopPropagation()
阻止事件冒泡。.prevent
event.preventDefault()
阻止默认事件行为。.capture
.self
.once
.passive
{ passive: true }
模式添加监听器,表示不会调用preventDefault()
。这些修饰符可以单独使用,也可以组合使用。以下是一些示例:
使用这些事件修饰符可以使你的事件处理逻辑更简洁和直观,同时也能够实现一些复杂的事件处理方式。
The text was updated successfully, but these errors were encountered: