【问题标题】:Vue 3 + TypeScript TS2614: Module '"*.vue"' has no exported memberVue 3 + TypeScript TS2614:模块 '"*.vue"' 没有导出成员
【发布时间】:2021-12-09 22:03:52
【问题描述】:

我正在尝试在一个组件中进行命名导出,如下所示:

export interface ITest { t: String }

从另一个人那里调用它:

import { ITest } from '@/components/Test.vue'

并且有错误:

TS2614: Module '"*.vue"' has no exported member 'ITest '. Did you mean to use 'import ITest from "*.vue"' instead?

如果我改为: import ITest from '@/components/Test.vue'

错误现在说: Module '"(path)/Test.vue"' has no default export. Did you mean to use 'import { ITest } from "(path)/Test.vue"' instead?

如何使用 TypeScript 在 Vue 中进行命名导出?

Vue 3、TypeScript、Webpack 5。

【问题讨论】:

    标签: typescript vue.js webpack export vuejs3


    【解决方案1】:
    export interface ITest { 
      t: string; 
    } 
    
    • Test.vue 更改为Test.ts,并将其导入到哪里。
    • 将类型String更改为打字稿类型string

    【讨论】:

    • 这个答案解决了问题吗?
    猜你喜欢
    • 2019-10-01
    • 2021-10-17
    • 2020-10-15
    • 1970-01-01
    • 2021-05-26
    • 2019-06-04
    • 1970-01-01
    • 2023-02-03
    • 2022-01-21
    相关资源
    最近更新 更多