Git Product home page Git Product logo

Comments (2)

nuysoft avatar nuysoft commented on June 2, 2024 2
Mock.mock(template, regulation)

由于 regulation 的格式和可选值太多,在使用这个方法签名时会导致混乱,目前不考虑支持。

from mock.

nuysoft avatar nuysoft commented on June 2, 2024

目前不支持直接返回数组。
你所描述的这种场景也挺常见,受你的启发,Mock.js 接下来会考虑要不要增加一个新的方法签名 Mock.mock(template, regulation),例如:

Mock.mock([{ ... }], '5-10')

在实现上,会接近于现在的内部方法 Handle.gen(template, name, obj),或者仅仅是把该内部方法暴露出来。

如果你有更合适的方法签名或实现,非常欢迎提供建议和贡献代码。

另外,参考下我最初的想法:
属性名 data|5-10 定义了生成数据时的规则,所以是必须的。从接口是否易读易用的角度看,如果希望直接传入数据模板 [{ ... }],那么,生成数据所需的规则势必需要通过其他参数传入,反而不如直接定义在属性名中直观。

from mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.