在微信小遊戲裏引入 lodash 會報錯微信
因此得把lodash.js 裏面的源碼ui
var root = freeGlobal || freeSelf || Function('return this')();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
};源碼