gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 03:16:05 24 4
gpt4 key购买 nike

我正在学习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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com