Comments (2)
Mock.mock(template, regulation)
由于 regulation
的格式和可选值太多,在使用这个方法签名时会导致混乱,目前不考虑支持。
from mock.
目前不支持直接返回数组。
你所描述的这种场景也挺常见,受你的启发,Mock.js 接下来会考虑要不要增加一个新的方法签名 Mock.mock(template, regulation),例如:
Mock.mock([{ ... }], '5-10')
在实现上,会接近于现在的内部方法 Handle.gen(template, name, obj),或者仅仅是把该内部方法暴露出来。
如果你有更合适的方法签名或实现,非常欢迎提供建议和贡献代码。
另外,参考下我最初的想法:
属性名data|5-10
定义了生成数据时的规则,所以是必须的。从接口是否易读易用的角度看,如果希望直接传入数据模板[{ ... }]
,那么,生成数据所需的规则势必需要通过其他参数传入,反而不如直接定义在属性名中直观。
from mock.
Related Issues (20)
- Mock数据在 iframe 里不生效,是什么原因导致的呢? HOT 1
- http://mockjs.com/ 域名到期了,不能访问了 HOT 2
- mockjs.com到期了怎么办?自己搞一个 HOT 7
- 你们的官网域名到期了
- bug: 重写了upload属性为空对象{},导致业务中使用到xhr.upload. addEventListener时报错 HOT 4
- 先行断言的字符数量配置无效
- Mock.mock的回调函数可以获取请求的header信息吗?
- Mock.mock('@drange') 不生效 HOT 1
- 用mockjs拦截以后如何读取header中的数据 HOT 1
- req.header 有值吗? HOT 1
- How to use mock.js to generate response that has status 403 or 400 ? HOT 3
- 打包后get发送数组参数,接收只能接收到数组参数的最后一个
- 关于mockjs嵌套url匹配问题 HOT 1
- 响应头Content-Security-Policy "script-src 'self' 导致不能使用eval【BUG】 HOT 3
- 如何生成指定一个指定内容,随机长度的数组? HOT 7
- 返回的数据丢失属性值
- 版本1.1.0使用正则
- 希望不要将 "commander" 的版本设定成 "*" HOT 8
- 作者有支持ts类型的计划吗? HOT 3
- 🤩早在2019年,这个库就不在维护了,各位另寻出路 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mock.