如何重置精灵sapui5

How to reset a wizard sapui5

我有一个完成的向导,之后我想重置并返回到第一步,所有其他步骤都无效,就像最初一样。 我可以重置我的数据模型,但我总是在向导的最后一步结束

我猜你错过了以下行来重置进度:

oWizard.discardProgress(
    oWizard.getSteps()[0]
);

Discards all progress done from the given step(incl.) to the end of the wizard.

有关丢弃函数的 API 文档,请参阅 here。 该函数需要第一个 wizardStep 作为参数。

在每次进入向导时调用的函数中调用以下代码(不是 onInit,它只调用一次,最好是你的 onRouteMatched 方法)。

var oWizard = this.byId("myWizard");
var oFirstStep = oWizard.getSteps()[0];
oWizard.discardProgress(oFirstStep);
// scroll to top
oWizard.goToStep(oFirstStep);
// invalidate first step
oFirstStep.setValidated(false);