【发布时间】:2020-11-27 19:04:18
【问题描述】:
我正在尝试将外部 JS 函数从单独的文件导入到我在 TypeScript 上运行的 Vue.js 应用程序中。
products_table.js
function init_products_table() {
console.log('test')
}
export {init_products_table as initProductsTable}
然后我像这样将它导入到我的 Vue 组件中:
import { initProductsTable } from '../../products_table.js'
我得到这个编译错误:
TS7016:找不到模块“../../products_table.js”的声明文件。
【问题讨论】:
-
您是否在 tsconfig 文件中将 allowJs 设置为 true?
-
它有帮助!虽然 IDE 在导入部分仍然显示 TS7016 错误。但是编译器现在可以正常工作了。
标签: javascript typescript vue.js