未捕获(承诺):错误无法实例化对象 new 丢失 [英] Uncaught (in promise): Error Cannot instantiate object new is missing

查看:46
本文介绍了未捕获(承诺):错误无法实例化对象 new 丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制器:

Menu.Controller.js:

Menu.Controller.js:

sap.ui.define([
       "sapit/ext/utils/BaseController",
       "sap/ui/model/json/JSONModel",
       "sap/ui/model/Sorter",
       "sap/ui/model/Filter",
       "sapit/nova/model/constants",
       "sapit/ nova /model/formatter",
       "sapit/ nova /util/Helper",
       "sapit/ nova /util/Validator",
       "sapit/ nova /util/ItemService"
     ], function(BaseController, JSONModel, Sorter, Filter, constants, formatter, Helper, Validator, ItemService) {
       "use strict";

       return BaseController.extend("sapit.nova.controller.Menu", {

             formatter: formatter,
             helper: new Helper(),
             itemService: new ItemService(),


             onInit: function() {
               this.fragmentProcess = sap.ui.xmlfragment("sapit.nova.view.fragment.Process", this);
               // attach events
               this.getRouter().attachRouteMatched(jQuery.proxy(this.onRouteMatched, this));
             },
             onRouteMatched: function(oEvent) {
                 var oPage = this.byId("menuProcessor");
                 var sRouteName = oEvent.getParameter("name");

                 if (sRouteName === "Menu") {
                   // show fragment
                   this.helper.clearFragment(oPage);
                   this.helper.showFragment(oPage, this.fragmentProcess);
                 }

我有相应的 xml 视图作为 Menu.view.xml:

I have the corresponding xml view as Menu.view.xml:

mvc:View controllerName="sapit.nova.controller.Menu" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc">
    <Page id="menuProcessor" title="{i18n>menuPageTitle}" showNavButton="false">

    </Page>
</mvc:View>

我的路由器配置是:

"routes": [{
    "pattern": "/admin",
    "name": "Main",
    "target": ["menu"]
  },

  "targets": {
    "menu": {
      "viewName": "Menu",
      "viewLevel": 1,
      "controlAggregation": "masterPages"
    }

问题是当我运行此应用程序时,控件将转到 menu.controller 的 onInit (),但它不会转到 onRouteMatched,尽管它正在获取附加到此视图的路由器实例.

The problem is when I run this application control is going to onInit () of the menu.controller but it's not going to onRouteMatched although it's getting the instance of router attached to this view.

每次我运行这个应用程序时,我都会在进入 onInit() 后收到一个错误,其余的代码不起作用,视图也没有出现.

Every time i run this application i am getting an Error after entering the onInit() and rest of code doesn't work and view doesn't come up.

Uncaught (in promise) Error: Cannot instantiate object: "new" is missing!
    at constructor (sap-ui-core.js:640)
    at constructor (sap-ui-core.js:1601)
    at constructor (sap-ui-core.js:1571)
    at f (sap-ui-core.js:638)
    at f (sap-ui-core.js:284)
    at p (sap-ui-core.js:285)
    at _ (sap-ui-core.js:286)
    at Object.properties (sap-ui-core.js:286)
    at l (sap-ui-core.js:298)
    at B.getText (sap-ui-core.js:296)

你能在这方面给我建议吗.

Can you please suggest me in this regard.

谢谢!!

推荐答案

去掉 sap.ui.define 中的空格这可能是加载 Helper、Validator 和 ItemService 时的问题

Remove the spaces from sap.ui.define this might be a problem when loading Helper, Validator and ItemService

sap.ui.define([
        "sapit/ext/utils/BaseController",
        "sap/ui/model/json/JSONModel",
        "sap/ui/model/Sorter",
        "sap/ui/model/Filter",
        "sapit/nova/model/constants",
        "sapit/ nova /model/formatter",
        "sapit/ nova /util/Helper",
        "sapit/ nova /util/Validator",
        "sapit/ nova /util/ItemService"
    ],

这篇关于未捕获(承诺):错误无法实例化对象 new 丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆