在微信小游戏里引入 lodash 会报错
window._ = require("./js/thirdParty/lodash.js");
所以得把lodash.js 里面的源码
var root = freeGlobal || freeSelf || Function('return this')();
改成
/*
freeGlobal 和 freeSelf 都为 false, 因为微信直接注入了 window 和 self,
最终 Array = (Function('return this')()).Array 为 undefined,
只需要替换 root 的值即可
*/
var root = {
Array: Array,
Date: Date,
Error: Error,
Function: Function,
Math: Math,
Object: Object,
RegExp: RegExp,
String: String,
TypeError: TypeError,
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval
};