vue project single page

<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>

Guess you like

Origin www.cnblogs.com/cl94/p/12215983.html