我正在使用一个使用ES6箭头功能的小型库,但在Internet Explorer中无法正常工作,但在Edge是的。
// fill in empty spaces with random letters
if (options.fillBlanks) {
var lettersToAdd, fillingBlanksCount = 0, extraLetterGenerator;
if (typeof options.fillBlanks === 'function') {
extraLetterGenerator = options.fillBlanks;
} else if (typeof options.fillBlanks === 'string') {
lettersToAdd = options.fillBlanks.toLowerCase().split('');
extraLetterGenerator = () => lettersToAdd.pop() || (fillingBlanksCount++ && '');
} else {
extraLetterGenerator = () => LETTERS[Math.floor(Math.random() * LETTERS.length)];
}
var extraLettersCount = this.fillBlanks({puzzle, extraLetterGenerator: extraLetterGenerator});
if (lettersToAdd && lettersToAdd.length) {
throw new Error('Some extra letters provided were not used: ${lettersToAdd}');
}
if (lettersToAdd && fillingBlanksCount && !options.allowExtraBlanks) {
throw new Error('${fillingBlanksCount} extra letters were missing to fill the grid');
}
var gridFillPercent = 100 * (1 - extraLettersCount / (options.width * options.height));
console.log('Blanks filled with ${extraLettersCount} random letters - Final grid is filled at ${gridFillPercent.toFixed(0)}%');
}
return puzzle;
},
错误在这一行
extraLetterGenerator = () => lettersToAdd.pop() || (fillingBlanksCount++ && '');
extraLetterGenerator = () => LETTERS[Math.floor(Math.random() * LETTERS.length)];
var extraLettersCount = this.fillBlanks({puzzle, extraLetterGenerator: extraLetterGenerator});
如何解决?
上找到