Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
103 views
in Technique[技术] by (71.8m points)

vuecli3如何用post传图片文件(formdata)?

如图:
image.png
这是封装的接口请求方法。

我将传入的文件保存在data中。
image.png

然后提交方法中,用formdata对象来传
image.png

就报错:
image.png

通过控制台输出发现公共拦截里面没有请求的参数data为空。

这是为什么呢?该如何解决?

补充:
经过断点调试,发现其在http拦截中的config对象中,图片文件还有值,但是在axios中的dispatchRequest方法中被删除了。这是为什么?难道axios不支持formdata参数传入?


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

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...