我正在尝试加载this lazyload polyfill script进入我的 Magneto 2 项目。
代码可以工作,但有一个控制台错误,我正在尝试修复但没有成功。
Chrome 控制台: loading-attribute-polyfill.js 未捕获 ReferenceError:模块未定义 在加载属性-polyfill.js:263
Safari 控制台: ReferenceError:找不到变量:模块
我尝试通过 xml 将其加载到 head 中,在 phtml 模板中手动加载,也通过 requirejs-config.js 加载,都给出了相同的错误。
如果重要的话,我是通过 requirejs 加载它的,如下所示:
var config = {
deps: [
"js/vendor/loading-attribute-polyfill"
],
map: { ... }
};
有人在 magento 2 中实现了这个脚本而没有出现这个错误吗?我可以对脚本进行手动编辑来解决此问题吗?
干杯!!
最佳答案
您想使用哪个版本的 Polyfil?有很多版本https://github.com/mfranzke/loading-attribute-polyfill/tree/master/dist
UMD 看起来与 RequireJS 兼容,但可能需要更改配置。
关于javascript - Lazyload polyfill/Magneto 2 js 错误 "loading-attribute-polyfill.js Uncaught ReferenceError: module is not defined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67269921/