index.tsx设置全局headers报错

来源:9-4 【API连接】AJAX 异步获取推荐数据

幕布斯9304569

2021-10-12

老师您好,我在index.tsx import axios并加入axios.defaults.headers[‘x-icode’] = ‘BB9091AEAC3502C6’; 后会报错,如下图片描述
求解答,谢谢

写回答

2回答

weixin_幕布斯2176181

2022-01-04

//img.mukewang.com/szimg/61d39aac09d0e6b704350061.jpg

写成如下格式即可

0
0

阿莱克斯刘

2021-10-13

我刚刚在课程案例代码中删除并且重新安装axios以后没有出现你的问题,我怀疑是你的项目缓存的问题。可以尝试删除项目根目录的node_modules文件夹,然后重新执行npm install安装项目依赖。

0
3
幕布斯9304569
回复
GlitzFigo
{ "compilerOptions": { "noImplicitAny": false, "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", "plugins": [ { "name": "typescript-plugin-css-modules" } ] }, "include": [ "src" ] }
2022-01-04
共3条回复

React18 系统精讲 结合TS打造旅游电商平台

React18 精讲 + 结合 TS 实战 + 热门业务开发,获取必备技能

1993 学习 · 1015 问题

查看课程