nuysoft / Mock

A simulation data generator
http://mockjs.com
Other
19.53k stars 2.67k forks source link

一个页面中有多个Mock都有@increment,是共用一个变量的? #316

Open lcysgsg opened 6 years ago

lcysgsg commented 6 years ago

vue, 一个主路由中有一个 , video、audio、picture 是在其子路由中的

Mock.mock(/video/, {
  code: 0,
  "data|3-10": [
    {
      id: "@id",
      title: "第@increment()节 视频消防工作概述",
      url:
        '@pick("Alan Walker - All Falls Down.mp4", "Carissa Rae - Near or Far.mp4")'
    }
  ],
  msg: "success"
});

Mock.mock(/audio/, {
  code: 0,
  "data|3-10": [
    {      id: "@id",
      title: "第@increment()节 音频消防工作概述",
      url: '@pick("01 風衣.m4a", "02 我很愉快.m4a")'
    }
  ],
  msg: "success"
});

Mock.mock(/picture/, {
  code: 0,
  "data|3-10": [
    {
      id: "@id",
      title: "第@increment()节 图文消防工作概述",
      content: "@cparagraph(50,100)"
    }
  ],
  msg: "success"
});

得到的截图如下: image

image

image

怎么让 @increment 每次都从1开始?

henbenla commented 6 years ago

同问

lichenbuliren commented 5 years ago

同样遇到这个问题

gunsluo commented 5 years ago

同样的问题

wujianqi commented 5 years ago

我这个 https://github.com/wujianqi/shai 不会,:)

edgexie commented 5 years ago

如果想从0开始,那别用@increment()占位,直接用Mock.Random.increment(),试试

yamfeel commented 4 years ago

我也是,同求。

ilovejwl commented 4 years ago

看了源码之后,发现可以通过自减来进行归零操作,代码如下: Mock.Random.increment(-Mock.Random.increment())

cocoasui commented 2 years ago

可以先自定义一个自增属性,然后用占位符引用 { "myCount|+1": 1, "title": "第@myCount()节 视频消防工作概述", }