在这里,我尝试使用mixin在我的模块中扩展Amasty js小部件。我已经创建了如下所示的要求like config.js文件
var config = {
config: {
mixins: {
'amShopbyAjax': {
'vendor_CustomCatalog/js/amasty/amShopbyAjax-override': true
}
}
}
};我已经创建了如下js文件
define([
"jquery",
"jquery-ui-modules/widget"
], function ($) {
'use strict';
var amShopbyWidgetMixin = {
selectors: {
category_products_wrapper: '#amasty-shopby-category-product-list',
},
reloadHtml: function (data) {
console.log("Sdfsdfsdf");
return this._super();
},
callAjax: function (clearUrl, data, pushState, cacheKey, isSorting) {
console.log("sdnjkasndnsadj");
return this._super();
}
};
return function (targetWidget) {
$.widget('custom.amShopbyAjax', targetWidget, amShopbyWidgetMixin);
return $.custom.amShopbyAjax;
};
});之后,我运行sudo bin/magento setup:static-content:deploy -f并清除缓存,然后我得到“未捕获TypeError: base不是一个构造函数”错误
发布于 2021-06-02 19:35:09
我认为应该将custom.amShopbyAjax更改为mage.amShopbyAjax
return function (targetWidget) {
$.widget('mage.amShopbyAjax', targetWidget, amShopbyWidgetMixin);
return $.mage.amShopbyAjax;
};目标微件的微件别名应与目标微件的别名类似,并且应返回按父级别名的微件
https://stackoverflow.com/questions/60094680
复制相似问题