Subscribe on changes!

setup script语法下,defineAsyncComponent在component is为字符串时,组件不会被渲染

avatar
Jan 30th 2022

Version

3.2.29

Reproduction link

sfc.vuejs.org/

Steps to reproduce

setup script语法下defineAsyncComponent与component is为字符串时组件不会被渲染

What is expected?

component is指定的组件会被正常渲染

What is actually happening?

component is指定的组件实际没有被渲染


<script lang="ts" setup>
const DynInput = defineAsyncComponent(() => import('./form-item/DynInput.vue'))
const componentName = 'DynInput'
</script>
<template>
    <component :is="componentName" :item="item" :form-data="formData"></component>
</template>
avatar
Jan 30th 2022

Don't use a string, use the component directly. sfc

(the warning is because of SFC Playground not liking the import())