Vue3/TypeScript -不能导入接口bc.丢失的导出默认值?



我写了一个我想在我的组件中使用的接口。但是,似乎我不能真正导入接口,我不知道为什么。

下面是重要的代码:

我的界面在src/types/jobs .ts

interface Job {
  name: string,
  salary: string,
  isPopular: boolean
}
export default Job

和我的app . value设置函数&进口:

<script lang="ts">
import { defineComponent, ref } from 'vue'
import Job from './types/Job'
export default defineComponent({
  setup() {
    const jobs = ref<Job[]>([
      {
        ...
      },
      {
        ...
      }
    ])
    return { jobs }
  }
})

作为一个错误,我得到以下内容:

Uncaught SyntaxError: The requested module '/src/types/Job.ts' does not provide an export named 'default' (at App.vue:55:8)

我真的很想知道为什么或者什么不见了。有人知道吗?

尝试在导入关键字后添加type:

import type Job from './types/Job'

最新更新