vue事件修饰符

.stop

阻止事件冒泡
父子元素都有事件绑定的时候, child.stop会阻止事件向上传递

.capture

事件捕获

.once

只执行一次

.self

只有触发自身事件时才执行(不受冒泡和捕获影响)

.prevent

阻止默认行为

<a href='http://www.uplyw.com' @click.prevent="jump">a>

<div id="app">
    <div @click="parend">parent
        <div @click="child">child
            <div @click.stop="grandson">grandsondiv>
        div>
    div>
div>
<script src="./vue/2.5.14/vue.js">script>
<script>
    let vm = new Vue({
        el:"#app",
        data:{
            
        },
        methods: {
            parend(){
                console.log('parend');
            },
            child(){
                console.log('child');
            },
            grandson(){
                console.log('grandson');
            },
        }

你可能感兴趣的:(vue,javascript)