在SAPUI5中匹配无效哈希时如何显示NotFound

在SAPUI5中匹配无效哈希时如何显示NotFound,sapui5,Sapui5,我使用SAPUI5执行了捕获和处理无效哈希的步骤,但我的应用程序无法工作 当我尝试导航到NotFound视图更改哈希时,我只收到一条信息消息: 但视图不会显示 [编辑]: 添加源代码文件: 这里我添加了绕过的部分 我已经在清单的Targets部分创建了目标: 这是NotFound.controller.js sap.ui.define([ "my/path/controller/BaseController" ], function (BaseController) { "use

我使用SAPUI5执行了捕获和处理无效哈希的步骤,但我的应用程序无法工作

当我尝试导航到NotFound视图更改哈希时,我只收到一条信息消息:

但视图不会显示

[编辑]:

添加源代码文件:

这里我添加了绕过的部分

我已经在清单的Targets部分创建了目标:

这是NotFound.controller.js

sap.ui.define([
   "my/path/controller/BaseController"
], function (BaseController) {
"use strict";

return BaseController.extend("my.path.controller.NotFound", {

    onInit: function () {
        var oRouter, oTarget;

        oRouter = this.getRouter();
        oTarget = oRouter.getTarget("NotFound");
        oTarget.attachDisplay(function (oEvent) {
            this._oData = oEvent.getParameter("data");  // store the data
        }, this);
    },

    // override the parent's onNavBack (inherited from BaseController)
    onNavBack : function (oEvent){
        // in some cases we could display a certain target when the back button is pressed
        if (this._oData && this._oData.fromTarget) {
            this.getRouter().getTargets().display(this._oData.fromTarget);
            delete this._oData.fromTarget;
            return;
        }

        // call the parent's onNavBack
        BaseController.prototype.onNavBack.apply(this, arguments);
    }

});
}))

这里是NotFound.view.xml:

<mvc:View
   controllerName="my.path.controller.NotFound"
   xmlns="sap.m"
   xmlns:mvc="sap.ui.core.mvc">
   <MessagePage
      title="{i18n>NotFound}"
      text="{i18n>NotFound.text}"
      description="{i18n>NotFound.description}"
      showNavButton="true"
      navButtonPress="onNavBack"/>
</mvc:View>
及 有人能帮我吗? 关于,

请检查此插销:

manifest.json上的密钥配置如下:

 "targets": {
                "tgHome": {
                    "viewPath": "sapui5Example",
                    "viewName": "home"
                },
                "notFound": {
                    "viewPath": "sapui5Example",
                    "viewName": "NotFound",
                    "transition": "show"
                }
            }
要启动“找不到”路由,请下载plunker并在URL中,在散列之后键入任何内容,然后您将打开“找不到”页面(如果您直接在plunker上执行此操作,它将不起作用)。这是一张照片:


如果您执行了这些步骤,请提供您的源代码=),特别是manifest.json的路由部分和执行导航的一段代码。请尝试在“NotFound”目标中添加
“transition”:“show”
。通过比较,我发现您的代码中缺少了。您是否将
NotFound
路由添加到
manifest.json
 "targets": {
                "tgHome": {
                    "viewPath": "sapui5Example",
                    "viewName": "home"
                },
                "notFound": {
                    "viewPath": "sapui5Example",
                    "viewName": "NotFound",
                    "transition": "show"
                }
            }