例如
//选取1个
"_card_Currency|1": ["人民币", "美元", "日元", "全币种", "港币"]
//重复2次(我要的不是重复)
"_card_Currency|2": ["人民币", "美元", "日元", "全币种", "港币"]
Mock.Random.extend({
constellations: [
{ image: "../../images/shopDetail/df1.png", name: "可预约" },
{ image: "../../images/shopDetail/df2.png", name: "提供WIFI" },
{ image: "../../images/shopDetail/df3.png", name: "免费停车" },
{ image: "../../images/shopDetail/df4.png", name: "内设包厢" }
],
//自定义占位符名字tags
tags: function (date) {
//随机选择2个作为返回值
//return this.pick(this.constellations, 2)
//随机选择2-4个作为返回值
return this.pick(this.constellations, 2, 4)
},
})
数据占位符 DPD
使用 @tags
Random.pick(['a', 'e', 'i', 'o', 'u'], 2, 4); // 从给定元素中挑选出指定数量的不重复数组。 即使第二个参数大于给定数组长度时,返回的数组长度也不会超过给定数组长度。
表达的不清楚,你可以直接把期待结果展示出来。