<div id="app">
        <input type="radio" v-model="radio" value="home"> home
        <input type="radio" v-model="radio" value="list"> list
        <!--一般用于缓存  为后面的路有做准备 如用缓存 就不会走 created mounted 钩子函数-->
        <keep-alive>
            <component :is="radio"></component>
        </keep-alive>
    
    </div>

   <script>
        let home={ template:"<div>home</div>"}
        let list={ template:"<div>list</div>"}
        let vm = new Vue({
            el:'#app',
            data:{
                radio:'home'
            },
            components:{
                home,list
         }
        })
    </script>
Last modification:March 21st, 2020 at 05:56 pm
如果觉得我的文章对你有用,请随意赞赏