เงื่อนไข
ฉันมี 2 วิดเจ็ตที่กำหนดเองที่ขยายวิดเจ็ตหลักเดียวกัน
- วิดเจ็ตหลัก: Magento_ConfigurableProduct/js/configurable
- วิดเจ็ตที่กำหนดเองครั้งแรก: Vendor_AModule/js/configurable
- วิดเจ็ตที่กำหนดเองที่สอง: Vendor_BModule/js/configurable
วิดเจ็ตที่กำหนดเองครั้งแรกrequire-config.js:
var config = {
    map: {
        '*': {
            configurable: 'Vendor_AModule/js/configurable'
        }
    }
};วิดเจ็ตที่กำหนดเองครั้งแรก JS:
define([
    'jquery',
    'mage/translate',
    'Magento_ConfigurableProduct/js/configurable'
], function ($) {
    $.widget('vendor.configurable_awidget', $.mage.configurable, {
        /**
         * {@inheritDoc}
         */
        _configureElement: function (element) {
            this._super(element);
            alert('Custom widget A is triggered!');
        }
    });
    return $.vendor.configurable_awidget;
});วิดเจ็ตที่กำหนดเองที่สองrequire-config.js:
var config = {
    map: {
        '*': {
            configurable: 'Vendor_BModule/js/configurable'
        }
    }
};วิดเจ็ตที่กำหนดเองที่สอง JS:
define([
    'jquery',
    'mage/translate',
    'Magento_ConfigurableProduct/js/configurable'
], function ($) {
    $.widget('vendor.configurable_bwidget', $.mage.configurable, {
        /**
         * {@inheritDoc}
         */
        _configureElement: function (element) {
            this._super(element);
            alert('Custom widget B is triggered!');
        }
    });
    return $.vendor.configurable_bwidget;
});ขั้นตอนในการทำซ้ำ
ฉันเปิดหน้าส่วนกำหนดค่าผลิตภัณฑ์
ผลลัพธ์ที่คาดหวัง
ฉันเห็นทั้งคู่Custom widget B is triggered!และCustom widget A is triggered!ตื่นตัว
ผลลัพธ์ที่แท้จริง
ฉันเห็นการCustom widget B is triggered!แจ้งเตือนเท่านั้น
คำถาม
รหัสควรทำให้หน้าส่วนผลิตภัณฑ์ที่สามารถกำหนดค่าได้แสดงการแจ้งเตือนของทั้งสองวิดเจ็ตอย่างไร
mixin