简体   繁体   English

模块 '"*.vue"' 没有导出的成员 'Hoge'。 您的意思是改用“从“*.vue”导入会议吗?ts(2614)

[英]Module '"*.vue"' has no exported member 'Hoge'. Did you mean to use 'import Meeting from "*.vue"' instead?ts(2614)

Summery夏天的

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.我想知道如何解决这个错误。

what I've tried我试过的

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.

相关问题 Vue 3 + TypeScript TS2614:模块 &#39;&quot;*.vue&quot;&#39; 没有导出成员 - Vue 3 + TypeScript TS2614: Module '"*.vue"' has no exported member 模块“domhandler”没有导出成员“DomElement”。 您的意思是使用“从“domhandler”导入 DomElement 吗? - Module '"domhandler"' has no exported member 'DomElement'. Did you mean to use 'import DomElement from "domhandler"' instead? TS2614:模块没有导出成员“NextHandleFunction” - TS2614: Module has no exported member 'NextHandleFunction' 模块 &#39;&quot;@react-native-firebase/firestore&quot;&#39; 没有导出成员 &#39;CollectionReference&#39;。 ts(2614) - Module '"@react-native-firebase/firestore"' has no exported member 'CollectionReference'. ts(2614) chart.js 没有名为“ChartDataSets”的导出成员。 您指的是“图表数据集”吗? TS(2724) - chart.js has no exported member named 'ChartDataSets'. Did you mean 'ChartDataset'? ts(2724) 模块没有导出的成员 Vue3 - Module has no exported Member Vue3 Vue / Typescript,得到模块 &#39;&quot;*.vue&quot;&#39; 没有导出成员 - Vue / Typescript, got Module '"*.vue"' has no exported member Vue 3:模块 '"../../node_modules/vue/dist/vue"' 没有导出成员 - Vue 3: Module '"../../node_modules/vue/dist/vue"' has no exported member 使用 tsx 时,vue/ 没有导出成员“toRefs” - vue/ has no exported member 'toRefs' when use tsx Vue组件导入接口时如何避免TS2614错误 - How to avoid TS2614 error when importing interfaces from Vue components
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM