<template> <div> <div v-if="type === ‘A‘">A</div> <div v-else-if="type === ‘B‘">B</div> <div v-else-if="type === ‘C‘">C</div> <div v-else-if="type === ‘D‘">D</div> <div v-else>Not A/B/C</div> <div @click="c1()"> <div @click.stop="c2()"> <!--阻止冒泡--> click </div> </div> </div> </template> <script> export default{ data(){ return { type: "a", } }, computed : { }, methods : { c2 : function(){ alert(‘c2‘); }, c1 : function(){ alert(‘c1‘); }, } } </script>
原文地址:https://www.cnblogs.com/cl94/p/12215983.html
时间: 2024-10-08 06:13:24