Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock 无法拦截 带参数的 GET #109

Open
supidea opened this issue Apr 9, 2016 · 8 comments
Open

Mock 无法拦截 带参数的 GET #109

supidea opened this issue Apr 9, 2016 · 8 comments

Comments

@supidea
Copy link

supidea commented Apr 9, 2016

比如:
this.$http.get('/board_list',{id:111}).then(res=>{ this.boardList=this.boardList.concat(res.data.result); })

调试显示这个错误

mock.js:8275 GET http://127.0.0.1:8080/board_list?id=111 404 (Not Found)

我是 vuejs 的。。。如果把 get 换成 post 是可以的

@xjchenhao
Copy link

xjchenhao commented Aug 4, 2016

我也遇到了get请求无法被拦截,不是vue的原因,我把所有有关vue的代码都注释了,问题依然存在。

@CyberNika
Copy link

CyberNika commented Aug 30, 2016

我也遇到了相同的问题,使用的是 vue-resource,带参数的 get 请求无法被拦截

@JounQin
Copy link

JounQin commented Aug 30, 2016

Mock 的正则没写对吧?

@CyberNika
Copy link

我擦,尴尬 - -。对文档理解错了,现在改了正确的正则就好了

@zacard-orc
Copy link

能帮贴个示例吗?我mock拦截不到vue-resource

@AsceticBoy
Copy link

大写的GET不生效,用get

@Fnll
Copy link

Fnll commented Jul 6, 2017

@AsceticBoy

表示需要拦截的 Ajax 请求类型。例如 GETPOSTPUTDELETE 等。

文档上写的GET,然而只能小写╮(╯_╰)╭

@WeijianXu
Copy link

我也遇到这样的问题,后来将路径改成正则就好了,如:
刚开始:
Mock.mock('/api/healthPlat/renewCancel', 'get', manage.renewCancel);
debug时发现,带参数时失败,不带参数成功,改成 post 也成功。
改成下面这样就好了:
Mock.mock(/\/api\/healthPlat\/renewCancel/, 'get', manage.renewCancel);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants