【发布时间】:2020-07-07 01:31:51
【问题描述】:
suitecommerce 核心代码中有一个视图 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 方法时, 无法读取未定义的属性“isActiveVal”类型错误:无法读取未定义的属性“isActiveVal”。尽管 isActiveVal 在 OrderWizard 视图中可用。
当调用 setAddressExt 我得到“这是未定义的”。
有人可以帮助我在这里做错了什么。从扩展中调用suitecommerce核心代码方法的最佳方法是什么。我想我没有传递OrderWizard视图的实际上下文(.apply(this)。
【问题讨论】:
-
想出了解决方案。将在答案部分添加解决方案。