- size: 指示图片的宽高,格式为 '宽x高'。默认从下面的数组中随机读取一个:
['300x250', '250x250', '240x400', '336x280', '180x150', '720x300', '468x60', '234x60', '88x31', '120x90', '120x60', '120x240', '125x125', '728x90', '160x600', '120x600', '300x600']
- background: 指示图片的背景色。默认值为 '#000000'。
- foreground: 指示图片的前景色(文字)。默认值为 '#FFFFFF'。
- format: 指示图片的格式。默认值为 'png',可选值包括:'png'、'gif'、'jpg'。
- text: 指示图片上的文字。默认值为参数 size。
Mock.Random.image() // http://dummyimage.com/120x60 Mock.Random.image('200x100') // http://dummyimage.com/200x100 Mock.Random.image('200x100', '#FF6600') // http://dummyimage.com/200x100/FF6600 Mock.Random.image('200x100', '#4A7BF7', 'Hello') // http://dummyimage.com/200x100/4A7BF7&text=Hello Mock.Random.image('200x100', '#50B347', '#FFF', 'Mock.js') // http://dummyimage.com/200x100/50B347/FFF&text=Mock.js Mock.Random.image('200x100', '#894FC4', '#FFF', 'png', '!') //http://dummyimage.com/200x100/894FC4/FFF.png&text=!
Mock.Random.dataImage(size?, text?),生成一段随机的 Base64 图片编码。
- size: 指示图片的宽高,格式为 '宽x高'。默认从下面的数组中随机读取一个.
['300x250', '250x250', '240x400', '336x280', '180x150', '720x300', '468x60', '234x60', '88x31', '120x90', '120x60', '120x240', '125x125', '728x90', '160x600', '120x600', '300x600']
- text: 指示图片上的文字。默认值为参数 size。
Mock.Random.dataImage() // data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAA8CAYAAACtrX6oAAAAAXNSR0IArs4c6QAAA1NJREFUeF7tmL9OG0EQxschMUoiy1FQKgp6eAMqBLwGNNDxAIgGCQr+FFSIDgrgEWiBEp4AahrSRERBhhCfQhztSXMaNntmDsWRZ/JdZ/vz3sz3m5nduxrR5w7hcutADYDdss0TA2DffAHYOV8ABmDvDjjPD3swADt3wHl66GAAdu6A8/TQwQDs3AHn6aGDAdi5A87TQwcDsHMHnKeHDgZg5w44Tw8dDMDOHXCeHjoYgJ074Dw9d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