javascript - 类 sap.ui.core.mvc.View 的渲染器未定义或未定义渲染函数!将跳过渲染! -

标签 javascript jquery sapui5

我正在学习SAPUI5。在链接Plunkr 。我有几个问题。 我正在尝试创建一个 JS View 和一个 Controller 来玩。为什么我必须在 getCore() 中指定我的应用程序、页面。如果我在 getCore() 之外执行该操作会怎样?但是,一旦我在核心方法中初始化应用程序和页面,控制台就会抛出错误。详细的解释将会非常有帮助。谢谢:)`

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
    <script
      id="sap-ui-bootstrap"
      src= "https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
      data-sap-ui-theme="sap_bluecrystal"
      data-sap-ui-libs="sap.m"
      data-sap-ui-compatVersion="edge"
      data-sap-ui-preload="async"
    ></script>

    <script src="script.js"></script>
  </head>

  <body>
    <h1>Hello SAPUI5</h1>
    <div class="sapUiBody" id="content"></div>
    <div id="content1"></div>
  </body>

// Code goes here
//debugger
sap.ui.getCore().attachInit(function(){
  new sap.m.Text({
    text:"Hello World, SAPUI5"
  }).placeAt("content");

  var app = new sap.m.App({
        initialPage : "idViewDashboard1"
    });

 var page = new sap.ui.core.mvc.View({
        id : "idViewDashboard1",
        viewName:"ViewChartContainer",
        type : sap.ui.core.mvc.ViewType.JS
    });

    app.addPage(page);
    app.placeAt("content1");

});

`

The renderer for class sap.ui.core.mvc.View is not defined or does not define a render function! Rendering of idViewDashboard1 will be skipped! -

最佳答案

getCore() 返回 Core具有 attachInit() 的实例事件

will either be called as soon as the framework has been initialized or, if it has been initialized already, it will be called immediately.

由于内容是异步加载的,attachInit 是使用 ui5 框架构建应用程序的最佳位置,因为您可以信赖一切都可用且准备就绪。

您的 plunkr 会发出相当晦涩的错误消息,因为您创建了 sap.ui.core.mvc.View 类的空实例,该实例本应是抽象的,并且确实没有渲染器方法。至instantiate your view您应该使用 sap.ui.view() 方法:

var page = sap.ui.view({
        id : "idViewDashboard1",
        viewName:"viewChartContainer",
        type : sap.ui.core.mvc.ViewType.JS
    });

请参见此处:https://plnkr.co/edit/ErToSaYgyg7KJ3HX52Oj?p=preview

如果你想学习 UI5 我可以推荐你阅读 Walkthrough 。除了提到的 AttachInit() 之外,您还可以在那里阅读更多有用的模式,例如:将应用程序封装在组件中、使用 XMLViews、使用 AMD-Modules,...

关于javascript - 类 sap.ui.core.mvc.View 的渲染器未定义或未定义渲染函数!将跳过渲染! -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45524823/

相关文章:

javascript - knockout/JavaScript 忽略多重点击

javascript - 图像/视频以纵向纵横比覆盖整个屏幕

javascript - 在 html 代码中使用多个 jquery 和 javascript

javascript - 如何在 XML View 中添加没有 syle 信息的 sapUI5 面板?

javascript - 使用 this 和 prototype 在 JavaScript 中定义类的方法有什么区别?

php - 使用 php/mysql/jQuery 随机聊天

javascript - jQuery Ajax - 失败的资源或 Uncaught Error

javascript - JS Promise 回调 : Get named params instead of array

javascript - UI5 索引数据库 : store variables and call them later

sapui5 - SAP UI5 - 如何将 HTML DOM 对象附加到 XML View