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

Categories

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

Vue cli4.0 使用mockjs+axios模拟数据拿不到数据 返回404

我在src目录下新建了mock文件夹,并在其下创建一个api.js文件,如图:
image.png
api.js代码如下:
image.png
拦截ajax请求我用的是Mock.mock( rurl, rtype, template )这样的写法,
然后我在main.js里设置了一个mock开关,用来控制mock模拟数据的引入路径。如下:
image.png
在组件里用axios发送请求:
image.png
结果出现如下如下错误
image.png
我感觉是接口配置的问题,上午还出现用户名为空的情况,没有报错,但是被axios的拦截器接口错误拦截了,返回了用户名为空的情况,请各位大哥帮帮忙,多谢了


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

1 Answer

0 votes
by (71.8m points)

请问解决了吗,我也遇到这种情况


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...