vbenjs / vite-plugin-mock

A mock plugin for vite.use mockjs.
MIT License
626 stars 96 forks source link

url 是否支持占位符? #49

Open JexLau opened 3 years ago

JexLau commented 3 years ago

如下所示,接口中的[:ids]是占位符,但在文档中找不到这种写法

export default [
  {
    url: `/api/project/delete/:ids`,
    method: "delete",
    response: () => {
      return {
        code: 200,
        message: "ok",
        success: true,
      }
    },
  },
];
wangping1511 commented 2 years ago

如何获取 [:ids] 的值呢?

yanhao98 commented 2 years ago

如何获取 [:ids] 的值呢?

export default [
  {
    url: `/api/project/delete/:ids`,
    method: 'delete',
    response: (request: any) => {
      console.debug('request.url :>> ', request.url)
      return {
        code: 200,
        message: 'ok',
        success: true,
      }
    },
  },
] as MockMethod[]
mishengqiang commented 2 years ago

最新版本我看已经支持了,query能取到。

mishengqiang commented 2 years ago

57