mock 生成在线图片

1、需要用到库mockjs

yarn add mockjs

2、引入

const Random = require('mockjs').Random;

3、生成一张图片

Random.image('200x100');

返回结果是url格式:http://dummyimage.com/200x100
4、主要的配置参数

Random.image( size?, background?, foreground?, format?, text? )
// Random.image()
Random.image()
// Random.image( size )
Random.image('200x100')
// Random.image( size, background )
Random.image('200x100', '#FF6600')
// Random.image( size, background, text )
Random.image('200x100', '#4A7BF7', 'Hello')
// Random.image( size, background, foreground, text )
Random.image('200x100', '#50B347', '#FFF', 'Mock.js')
// Random.image( size, background, foreground, format, text )
Random.image('200x100', '#894FC4', '#FFF', 'png', '!')

你可能感兴趣的:(node)