【问题标题】:Migrating to Vite from Vue CLI (Vue 3): Uncaught (in promise) TypeError: Cannot destructure property 'default' of 'undefined' as it is undefined从 Vue CLI(Vue 3)迁移到 Vite:未捕获(承诺中)类型错误:无法解构“未定义”的属性“默认”,因为它未定义
【发布时间】:2022-01-08 05:32:34
【问题描述】:

我正在将我的 Vue 3 项目从 Vue CLI 迁移到 Vite,并且在测试时,我一直收到此错误:

Uncaught (in promise) TypeError: Cannot destruct property 'default' of 'undefined' 因为它是未定义的。

我有问题的 .vue 文件如下所示:

<template>
    <h1>Projects</h1>

    <ProjectList/>
</template>

<script>
import ProjectList from '@/components/ProjectList';

export default {
    components: {ProjectList},
    setup() {
        
    }
}

【问题讨论】:

    标签: vuejs3 vite


    【解决方案1】:

    原来问题是我忘记在我的导入中添加 .vue 扩展名。

    import ProjectList from '@/components/ProjectList.vue';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-07
      • 1970-01-01
      • 2020-09-18
      • 2018-10-29
      • 2020-12-15
      • 2017-08-12
      • 1970-01-01
      相关资源
      最近更新 更多