【发布时间】:2022-11-07 20:39:45
【问题描述】:
我写了一个我想在我的组件中使用的接口。但是,似乎我无法真正导入界面,也看不到原因。
这是重要的代码:
我在 src/types/Job.ts 中的界面
interface Job {
name: string,
salary: string,
isPopular: boolean
}
export default Job
还有我的 App.vue 设置功能和导入:
<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)
我真的很想知道为什么或缺少什么。任何人的想法?
【问题讨论】:
-
试试
import type Job from './types/Job' -
哦,那行得通,谢谢!我正在关注一个在导入之前没有添加“类型”的 youtube 教程,它在那里工作。真的很困惑,但谢谢!
标签: typescript vue.js vuejs3