我想随机返回文件夹中的图像,但出现错误“无效调用”
我的功能:
returnGif = () => {
min = Math.ceil(1);
max = Math.floor(53);
const gifNumber = Math.floor(Math.random() * (max - min +1)) + min;
var gifFont = require('../config/Images/Gifs/' + gifNumber + '_2.png');
if (gifFont) {
if (Math.random()>0.5) gifFont = require('../config/Images/Gifs/' + gifNumber + '_2.png');
else gifFont = require('../config/Images/Gifs/' + gifNumber + '.png');
}
else gifFont = require('../config/Images/Gifs/' + gifNumber + '.png');
return gifFont;
}