[英]Module '"*.vue"' has no exported member 'Hoge'. Did you mean to use 'import Meeting from "*.vue"' instead?ts(2614)
I've implemented Vue.js/Nuxt.js application.我已经实现了 Vue.js/Nuxt.js 应用程序。
In the application, I import vue file into typescript file.在应用程序中,我将 vue 文件导入到 typescript 文件中。
typescript file typescript 文件
import { Hoge } from '~/layouts/default.vue'
~/layouts/default.vue ~/layouts/default.vue
<script lang="ts">
export interface Hoge{
hoge: string
}
</script>
But I shows error on { Hoge }
saying Module '"*.vue"' has no exported member 'Hoge'. Did you mean to use 'import Meeting from "*.vue"' instead?ts(2614)
但是我在
{ Hoge }
上显示错误,说Module '"*.vue"' has no exported member 'Hoge'. Did you mean to use 'import Meeting from "*.vue"' instead?ts(2614)
Module '"*.vue"' has no exported member 'Hoge'. Did you mean to use 'import Meeting from "*.vue"' instead?ts(2614)
I want to know how to resolve this error.我想知道如何解决这个错误。
I already set index.d.ts
我已经设置
index.d.ts
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
I am not sure why you are trying to import a type from a vue file but this is what I recommend:我不确定您为什么要尝试从 vue 文件中导入类型,但这是我的建议:
Create a file /types/shared.ts
And add this inside:创建一个文件
/types/shared.ts
并在里面添加:
export interface Hoge{
hoge: string
}
Than you can import this interface like this:比你可以像这样导入这个接口:
import { Hoge } from '~/types/shared'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.