一、环境

yarn设置淘宝镜像源:

yarn config set registry https://registry.npm.taobao.org

yarn查询镜像源:

yarn config get registry

npm查询镜像源:

npm config list

npm设置镜像源:

npm set registry https://registry.npm.taobao.org/

清缓存:

npm cache clean --force

yarn cache clean

 

二、mock数据

两层数组+随机颜色的图片:

import Mock from 'mockjs'

let list = Mock.mock({
"list|3": [
{
'id|+1': 0,
'title': '@cname',
"list": () => Mock.mock({
"list|20": [
{
'id|+1': 1,
'title': '@ctitle',
'avatar': '@image(112x150, @color)',
}
]
}).list
}
]
}).list

let data = Mock.mock({
"list|10": [
{
'id|+1': 1,
'name': '@cname',
'title': '@ctitle',
//'image': Mock.Random.image(null, '#ff0000', '#ffff00', 'hello'),
'image': '@image(112x150, @color)',
'paragraph': '@cparagraph',
'datetime': '@datetime',
"color": "@color()"
}
]
}).list

Mock.mock("/api/mock", {
code: 200,
data: list,
message: 'mock数据'
})

1801A React 学习资料_镜像源