我正在将 LogEntries 集成到我的反应应用程序中。
但是在导入 LogEntryjs
文件之后。我收到控制台错误:
const Logger = require ('./logger.jsx')('your token', {trace: true});
错误:
le.min.js:5 Uncaught TypeError: Cannot read property 'LEENDPOINT' of undefined
at new e (le.min.js:5)
at new p (le.min.js:10)
at f (le.min.js:11)
at Object.init (le.min.js:12)
at module.exports (logger.jsx:9)
at Object.defineProperty.value (App.js:10)
at __webpack_require__ (bootstrap 9c287bdecc8b4481a87b:19)
at Object.defineProperty.value (AppWrapper.js:2)
at __webpack_require__ (bootstrap 9c287bdecc8b4481a87b:19)
at Object.<anonymous> (index.js:8)
更新:
调试后,我知道记录器文件中未定义窗口对象。这是一段造成严重破坏的代码:
if (window.LEENDPOINT) {
_endpoint = window.LEENDPOINT;
}
仍在寻找解决方案。
更新 2.0:
这是我的 Logger.jsx
const LogEntries = require ('./le.min.js');
module.exports = (token, opts={}) => {
if(!token){
throw new Error ('A valid token is required for all LogEntries library implementations.');
}
opts.token = token;
LogEntries.init(opts);
return LogEntries;
}