在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue 使用componet動態(tài)組件實現(xiàn)動態(tài)切換如何import單頁組件模板?

vue 使用componet動態(tài)組件實現(xiàn)動態(tài)切換如何import單頁組件模板?

父組件:item.index.vue

<template>
    <div>
        <compoent :is="comp"></compoent>
    </div>
</template>
<script>
    export default {
        computed: {
            comp: function () {
                return import('./component/item1.form')
        }
    },
}
</script>

子組件:item1.form.vue

<template>
    <div>
        111
    </div>
</template>
    
<script>
    export default {
        data () {
            return {
                msg: 'hello'
            };
        }
    };
</script>

報錯信息

clipboard.png

回答
編輯回答
掛念你

return() => import('./component/item1.form')
如果import有變量,那么需要使用字符串模板解析
return () => import(./component/item${this.formItem.item_type}.form);

2018年8月7日 01:07