knockout.js - Uncaught ReferenceError: Unable to process binding "if: function(){return (addressOptions.length > 1) }" 消息:addressOptions 未定义
问题描述
我已将 Magento2.3.1 更新为 Magento2.3.2。当继续结帐时,我收到数据绑定错误 -
knockout-3.4.1.js:72 Uncaught ReferenceError: Unable to process binding "if: function(){return (addressOptions.length > 1) }" 消息:addressOptions 未定义
当我在我的 magento 文件夹中搜索关键字 addressOptions 时,文件路径是:/vendor/magento/module-checkout/view/frontend/web/template/billing-address/list.html 并且 html 文件中的代码是:
<div class="field field-select-billing">
<label class="label"><span data-bind="i18n: 'My billing and shipping address are the same'"></span></label>
<div class="control" data-bind="if: (addressOptions.length > 1)">
<select class="select" name="billing_address_id" data-bind="
options: addressOptions,
optionsText: addressOptionsText,
value: selectedAddress,
event: {change: onAddressChange(selectedAddress())};
"></select>
</div>
</div>
错误如下所示knockout.js 如果有人知道请帮助我。提前致谢。
解决方案
我能够解决重写我购买的自定义插件的 billing-address.html 模板的问题。在此模板中,以这种方式包含帐单地址列表模板:
<!-- ko template: 'Magento_Checkout/billing-address/list' --><!-- /ko -->
而在 magento 的核心中,模板是以这种方式包含的:
<each args="getRegion('billing-address-list')" render="" />
所以我在我的模板中进行了这个更改,我不再收到错误。也许在最新的 Magento2.3 版本中关于包含此类模板的内容有所改变?