vue 事件修饰符(阻止默认行为和事件冒泡)

1. 原生js中,阻止事件冒泡,获取点击对象,  e.stopPropagation();
2. vue阻止事件冒泡@click.stop="show" 
<body>
    <div id="myApp" @click="show2()">
        <div @click="show1()">
            <button @click.stop="show">vue点我button>
        div>
    div>
body>

<button @click.stop="doThis">button>

<button @click.prevent="doThis">button>

<form @submit.prevent>form>

<button @click.stop.prevent="doThis">button>

<button v-on:click.once="doThis">button>

<input @keyup.enter="onEnter">

<input @keyup.13="onEnter">

转载于:https://www.cnblogs.com/ceceliahappycoding/p/11321908.html

你可能感兴趣的:(javascript)