微信小程序 坑

  lodash 会报错, 得改成下面的形式

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
};

猜你喜欢

转载自www.cnblogs.com/zhengming2016/p/9263187.html