微信基础库2.10.0报错 module is not defined,但是微信后台没有截获?
js文件引用 utils/first-paint-report.js发布线上后报错,本地开发完全没问题。全是2.10.0版本的。怀疑是不是该版本有问题呢? 公司自己的监控平台抓获报错如下: [图片] 这个first-paint-report的代码如下: function wxPage (config) {
if (!(config.networkId && config.paintId)) {
return Page(config);
}
let modify_wx_page_init_paint_time_start = 0;
wxPage.onLoadCalcTime = function (paintId, networkId, time) {
if (wx.reportPerformance) {
const pages = getCurrentPages();
const current = pages[pages.length - 1];
const path = current && current.route;
wx.reportPerformance(paintId, time, `${path}[onLoad]`); // 加载/渲染类,生命周期内耗时
wx.reportPerformance(networkId, time, `${path}[onLoad]`); // 网络类,生命周期内耗时
}
}
wxPage.onReadyCalcTime = function (paintId, networkId, time) {
if (wx.reportPerformance) {
const pages = getCurrentPages();
const current = pages[pages.length - 1];
const path = current && current.route;
wx.reportPerformance(paintId, time, `${path}[onReady]`); // 加载/渲染类,生命周期内耗时
wx.reportPerformance(networkId, time, `${path}[onReady]`); // 网络类,生命周期内耗时
}
}
function modifyOnLoad () {
modify_wx_page_init_paint_time_start = new Date().getTime();
if (config.onLoad) {
config.onLoad.apply(this, arguments); // eslint-disable-line no-invalid-this
}
}
function modifyOnReady () {
if (wx.reportPerformance) {
const modify_wx_page_init_paint_time_end = new Date().getTime();
const modify_wx_page_init_paint_time = modify_wx_page_init_paint_time_end - modify_wx_page_init_paint_time_start;
const pages = getCurrentPages();
const current = pages[pages.length - 1];
const path = current && current.route;
wx.reportPerformance(config.paintId, modify_wx_page_init_paint_time, path); // 加载/渲染类,首次渲染时间
wx.reportPerformance(config.networkId, modify_wx_page_init_paint_time, path); // 网络类,首次渲染时间
}
if (config.onReady) {
config.onReady.apply(this, arguments); // eslint-disable-line no-invalid-this
}
}
const modifyConf = {
...config,
onLoad: modifyOnLoad,
onReady: modifyOnReady
}
return Page(modifyConf)
}
module.exports = wxPage;