Skip to content

umi 是如何实现mock 服务的? #7786

Answered by xiaohuoni
Wangggym asked this question in Q&A
Discussion options

You must be logged in to vote

通过服务中间件实现

  api.addBeforeMiddlewares(async () => {
    context.mockData = getMockData({
      cwd: api.cwd,
      mockConfig: api.config.mock || {},
    });
    return [
      createMockMiddleware({
        context,
      }),
    ];
  });

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by xiaohuoni
Comment options

You must be logged in to vote
1 reply
@xiaohuoni
Comment options

Comment options

You must be logged in to vote
2 replies
@zjfresh
Comment options

@JinXuchen2020
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants