suitecommerce核心code.It中有一个视图OrderWizard模块视图具有类似于下面的方法(不是确切的代码,不是为专有问题粘贴的)。我已经创建了扩展并从扩展调用OrderWizard的方法。
**setAddr: function(xxx, xxxx) {
this.model.setAddress(xxx, xxxx, xxxx);
return this;
}
renderView: function() {
if (!this.isActiveVal()) {
return this;
}
}**
Extension class:
**define(
'TEST.PaymentValidation.PaymentValidation'
, [
'OrderWizard.xxxxx.xxxxx'
]
, function (
OrderWizardAddress
)
{
'use strict';
return {
mountToApp: function mountToApp (container)
{
_.extend(OrderWizardAddress.prototype,
{
setAddressExt: function setAddressExt() {
{
OrderWizardAddress.prototype.setAddr.apply(this, arguments);
}
}
});
_.extend(OrderWizardAddress.prototype,
{
renderExt: function renderExt() {
{
OrderWizardAddress.prototype.renderView.apply(this, arguments);
}
}
});
OrderWizardAddress.prototype.setAddressExt();
OrderWizardAddress.prototype.renderExt();
}
};
});**
调用renderExt方法时,无法读取未定义TypeError的属性“”isActiveVal“”:无法读取未定义的属性“”isActiveVal“”。“”即使在OrderWizard视图中也可以使用isActiveVal。
当调用setAddressExt时,我得到‘这是未定义的’。
有没有人能告诉我我哪里做错了。从扩展中调用suitecommerce核心代码方法的最佳方式是什么?我猜我没有传递OrderWizard视图的实际上下文(.apply(这))。
发布于 2020-07-06 16:11:29
弄清楚了solution.Basically两个独立的视图必须相互通信,才能显示出它们的价值。付款视图和账单视图是两个不同的视图。根据选择的支付方式,默认计费地址需要使用selected.Used Backbone的事件队列聚合器方法来解决这个问题。选择付款方式后,发布者会向订阅者发送消息。如果付款方法为发票,则publisher将消息发布给subscriber,从而触发选择默认开单地址的方法。为了添加扩展中的新方法,使用了javascript原型,并向现有方法添加了代码,使用了下划线的wrap方法
https://stackoverflow.com/questions/62577034
复制