惠州网站制作软件,wordpress the7 下载,游戏开发物语最强8人,公司微网站制作记录项目创建后遇到的报错
1.类型“Window typeof globalThis”上不存在属性“_CONFIG”。ts(2339)
问题描述#xff1a;
使用全局 window 上自定义的属性#xff0c;TypeScript 会报属性不存在
解决#xff1a;需要将自定义变量扩展到全局 window 上#xff0c…记录项目创建后遇到的报错
1.类型“Window typeof globalThis”上不存在属性“_CONFIG”。ts(2339)
问题描述
使用全局 window 上自定义的属性TypeScript 会报属性不存在
解决需要将自定义变量扩展到全局 window 上在项目的xxx.d.ts文件添加如下代码声明
declare interface Window {_CONFIG: any
}添加后好像得重启编译器
2.axios报错
2.1 问题描述 这个报错是因为axios版本更新后出现了新的类型导致的问题可以根据此贴中的描述来解决也可以用回旧版本解决我是用回了0.21.x的旧版本
yarn add axios^0.21.12.2 类型“AxiosResponse”上不存在属性“success”。ts(2339) 解决封装文件中追加声明描述
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from axiosdeclare module axios {interface AxiosResponseT any {result:anysuccess:any,// 这里追加你的参数}export function create(config?: AxiosRequestConfig): AxiosInstance;
}3.vue.config.js路径别名配置
module.exports defineConfig({transpileDependencies: true,lintOnSave: false,publicPath: /,outputDir: dist,chainWebpack: config {config.resolve.alias.set(, resolve(src)).set(assets, resolve(src/assets)).set(views, resolve(src/views)).set(comp, resolve(src/components))}
});4.项目引入第三方库的关键字报错
问题描述 这里就是第三方库的关键字DC报错了
解决还是在xxx.d.ts文件中追加关键字声明
declare var DC: any