vue @click.stop 阻止点击事件继续传播
<template>
<section class="Untitled-1">
<div class="div_one" @click="clk_one">
<div class="div_two" @click="clk_two"></div>
</div>
</section>
</template>
<script>
export default {
name: 'Untitled-1',
components: {},
data() {
return {
}
},
watch: {},
mounted() {
clk_one(){
console.log("1")
},
clk_two(){
console.log("2")
}
},
methods: {}
}
</script>
<style lang="scss" scoped >
</style>
打印 1,2
<template>
<section class="Untitled-1">
<div class="div_one" @click.stop="clk_one">
<div class="div_two" @click.stop="clk_two"></div>
</div>
</section>
</template>
<script>
export default {
name: 'Untitled-1',
components: {},
data() {
return {
}
},
watch: {},
mounted() {
clk_one(){
console.log("1")
},
clk_two(){
console.log("2")
}
},
methods: {}
}
</script>
<style lang="scss" scoped >
</style>
打印 1
@click.stop 阻止点击事件继续向下传播
浙公网安备 33010602011771号