概述
引入axios,如果没有,则在webstorm的终端执行:
安装成功:
import axios from 'axios' 没有报错
ps:添加axios库的时候,qs库也是被添加成功
如果没有使用qs.stringify()就传递参数,后端项目会报:
Optional int parameter 'userId' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type
用途:序列化数据,类似json.stringify(),不过两者虽然都是序列化参数,但是结果不一样,前者序列化结果是url后直接用userId=‘晃晃晃’&password=‘123456’,而后者是{'userId':'huanghuanghuang','password':'123456'}
场景类似,用途不一样,qs.stringify是用来处理url的,JSON.stringify是处理json的
最后
以上就是默默铃铛为你收集整理的webstorm vue项目 axios.post请求带参数问题的全部内容,希望文章能够帮你解决webstorm vue项目 axios.post请求带参数问题所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复