Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在reactjs中键入axios_Reactjs_Axios - Fatal编程技术网

如何在reactjs中键入axios

如何在reactjs中键入axios,reactjs,axios,Reactjs,Axios,存在如上所述的axios typescript错误。 axios方法根据changeMethod状态值进行更改 index.d.ts(48,2):预期的类型来自属性'method',该属性在类型'AxiosRequestConfig'上声明。 为了消除此错误,我需要一些关于在axios中在何处键入声明的帮助。像这种联合类型一样进行修复如何。 你好,韩国人民:) 从“axios”导入{Method}; ... 常量handleSubmit=()=>{ axios({ 方法:将方法更改为方法, ur

存在如上所述的axios typescript错误。 axios方法根据
changeMethod
状态值进行更改

index.d.ts(48,2):预期的类型来自属性'method',该属性在类型'AxiosRequestConfig'上声明。


为了消除此错误,我需要一些关于在axios中在何处键入声明的帮助。

像这种联合类型一样进行修复如何。
你好,韩国人民:)

从“axios”导入{Method};
...
常量handleSubmit=()=>{
axios({
方法:将方法更改为方法,
url:changeSubmitValue,
响应类型:'stream'
}).然后(功能(响应){
控制台日志(响应);
});
};

其中是
changeMethod
changemsubmitvalue
来自哪里?
changeMethod
显然是
字符串类型,太宽了。请告诉我们您在哪里定义该变量。祝您好运:)한국 사람 만나서 반갑네요 ㅎㅎㅎ@苏扬:如果答案解决了你的问题,请接受。
    const handleSubmit = () => {
        axios({
            method: changeMethod,
            url: changeSubmitValue,
            responseType: 'stream'
        }).then(function(response) {
            console.log(response);

        });
    };