vvvvvv异步组件儿

const AsyncCommonItem = Vue.defineAsyncComponent(()=>{
    return new Promise((resolve,reject)=>{
        setTimeout(()=>{
            resolve({
                template:`<div>AsyncCommonItem</div>`
            })
        },3000)
    })
})

const app = Vue.createApp({
    data(){
        return {
            //currentItem:'input-item'
        }
    },
    methods:{
        zmf(){
            //this.currentItem = this.currentItem === 'input-item'?'common-item':'input-item'
        }
    },
    template:`
        <div>
            <common-item />
            <async-common-item />
        </div>
    `
})

app.component('common-item',{

    template:`
        <div>
            common-item
        </div>
    `
})

app.component('async-common-item',AsyncCommonItem)

const vm = app.mount('#root')

 

posted on 2021-06-22 17:12  ZKJABLE  阅读(105)  评论(0编辑  收藏  举报

导航