会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133439个问题
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 48楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 49楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 50楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 52楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 53楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 54楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 55楼

<template>
    <div>
        <button @cilck="showA">A组件</button>
        <button @click="showB">B组件</button>
        <button @click="showC">kong组件</button>
        <keep-alive>
            <component :is="current"></component>
        </keep-alive>
        

        动态组件    
    </div>
</template>

<script>
import AComponent from "./child/AComponent";
import BComponent from "./child/BComponent";
export default {
    name:"dongtai_components",
    data(){
        return{
            current:AComponent,

        }
    },
    components:{
        AComponent,
        BComponent,
    },methods:{
        showA(){
            this.current=AComponent;
        },
        showB(){
            this.current=BComponent;
        },showC(){
            this.current=AComponent;
        }


    }
}
</script>
<template>
    <div>
        AComponentaaa
    </div>
</template>
<script>
export default {
    name:"AComponent",
    data(){
        return{

        }
    }
}
</script>
<template>
    <div>
        BComponent
        {{msg}}
        <button @click="handle">改变数据</button>
        
    </div>
</template>
<script>
export default {
    name:"BComponent",
    data(){
        return{
            msg:"原有数据"

        }
    },
    methods:{
        handle(){
            this.msg="这是修改后的数据"

        }
    }
}
</script>

老师我这个showA点击之后没效果,而且把整个showA删除之后,后面两个事件也没效果了。是怎么回事

WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 56楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 57楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 58楼
WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 60楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637