外贸网站建站案例公司怎么在百度上推广
vue事件修饰符
- 1、目标
- 2、语法
1、目标
在事件后面.修饰符名-给事件带来强大功能
2、语法
@事件名.修饰符=“methods里的函数”
修饰符列表
- .stop - 阻止事件冒泡
示例:
<template><div id="app"><div @click="fatherFn"><p @click="oneFn">.stop事件-阻止冒泡</p></div></div></template><script>export default {//定义函数methods:{fatherFn(){console.log("father-触发了点击事件")},oneFn(){console.log("P标签点击了") }}}
</script>
- .prevent -阻止默认行为
示例:
<template><div id="app"><div @click="fatherFn"><a href="http://www.baidu.com" @click.prevent.stop>去百度</a></div></div></template><script>export default {//定义函数methods:{fatherFn(){console.log("father-触发了点击事件")},}}
</script>
- .once -程序运行期间,只触发一次事件处理函数。
示例:
<template><div id="app"><div ><p @click.once="twoFn">点击观察事件处理函数执行几次</p></div></div></template><script>export default {//定义函数methods:{fatherFn(){console.log("father-触发了点击事件")},twoFn(){console.log("p标签被点击了")}}}
</script>