-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何生成指定一个指定内容,随机长度的数组? #505
Comments
试试应该满足你的需求吧 const test = 'abcdef'.split('')
mockjs.mock({
'array|4': [`@pick(${test})`]
})
mockjs.mock({
'array|1-4': [`@pick(${test})`]
}) |
可是我的原始数据是固定的数组内容吖。需要可以随机产生指定数组当中的内容。 |
const test = 'abcdef'.split('')
mockjs.mock({
'array|4': [`@pick(${test})`]
})
mockjs.mock({
'array|1-4': [`@pick(${test})`]
}) 这个会从test数组随机挑选然后生成长度随你指定,这个不是就满足你的需求吗,还是我理解清楚你的需求 |
哎还是不成,不过不是你这写法不成,而是mock不成。 |
Mock.mock({
Array1: () => Mock.Random.pick([`a`, `b`, `c(cc)`], 2, 3)
}) |
This comment was marked as resolved.
This comment was marked as resolved.
perfect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
想要输出一个 1~3 长度的数组,但是内容是指定的,要怎么写呐?
The text was updated successfully, but these errors were encountered: