Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

test.ts:

import axios from 'axios'
console.log(axios.get('https://www.xxx.com'))

image.png

报错:TS2339: Property 'get' does not exist on type 'typeof Axios'.

虽然可以这样解决,但是每次都要类型断言一次太麻烦了

import axios from 'axios'
console.log((axios as any).get('https://www.xxx.com'))

求大神指点指点


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
672 views
Welcome To Ask or Share your Answers For Others

1 Answer

axios是自带type声明的
问题应该是ide没有检索到axios声明文件。
先删除整个node_modules文件夹,在npm install试试?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...