YooooooO_0
YooooooO_0
  • 发布:2021-11-12 10:53
  • 更新:2021-11-12 10:53
  • 阅读:909

typescript 报错。没有合适的loader处理文件类型

分类:uni-app

在uni-app项目中使用typescript,编译的时候报错,说没有合适的loader处理文件类型

Module parse failed: Unexpected token (22:17)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

一开始在HBuilder中装typescript编译插件不行
用npm 在项目里装了个ts-loader,然后又配了个tsconfig.json,配置如下

{  
    "compilerOptions": {  
    "target": "es5",  
    "strict": true,  
    "module": "es2015",  
    "moduleResolution": "node"  
    },  
    "files": [  
        "typings/zgapp.d.ts"  
    ]  
}  

最后还还有一行报错:
ERROR Build failed with errors.

但是项目可以运行,ts文件也可以用

2021-11-12 10:53 负责人:DCloud_UNI_FXY 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复