gpt4 book ai didi

javascript - 如何将 XML View 传输到 JavaScript View /SAPUI5

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

我正在尝试将 xml BlockLayout 结构化代码转换为 js。但它无法正常工作,因为它没有显示任何 View 内容。我检查了聚合,发现有 Row 的单元格聚合和 sap.ui.Control 单元格的聚合。

JavaScript:

        var oLayout = new sap.ui.layout.VerticalLayout("Layout", {
content: [
new sap.ui.layout.BlockLayout("Block", {
content: [
new sap.ui.layout.BlockLayoutRow("Row", {
content: [
new sap.ui.layout.BlockLayoutCell("Cell1", {
content: [
new sap.m.Text("sample", {text: "test"})
]
})
]
})
]
})
]
});

var viewID = this.getView().sId;
viewID = viewID + "--detailPage-cont";
oLayout.placeAt(viewID);

当我检查调试器是否添加了某些内容时,我看到添加的内容没有单元格和文本。

enter image description here

最佳答案

希望这能有所帮助 https://jsbin.com/benogay/edit?html,js,output

<!DOCTYPE HTML>
<html>

<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8' />
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-libs="sap.m, sap.ui.table" data-sap-ui-theme="sap_bluecrystal">
</script>
<script>
sap.ui.define([
'sap/ui/core/mvc/Controller',
'sap/ui/layout/VerticalLayout',
'sap/ui/layout/BlockLayout',
'sap/ui/layout/BlockLayoutRow',
'sap/ui/layout/BlockLayoutCell',
'sap/m/Text'
], function(Controller, VerticalLayout, BlockLayout, BlockLayoutRow, BlockLayoutCell, Text) {
sap.ui.jsview("myView.Template", {
getControllerName: function() {
return "myView.Template";
},
createContent: function(oController) {
return new VerticalLayout({
content: new BlockLayout({
content: new BlockLayoutRow({
content: new BlockLayoutCell({
content: new Text({
text: "test"
})
})
})
})
});
}
});

Controller.extend("myView.Template", {
onInit: function(oEvent) {
},
});
});


var view = sap.ui.view({
type: sap.ui.core.mvc.ViewType.JS,
viewName: "myView.Template"
});
view.placeAt("content");
</script>
</head>

<body class="sapUiBody sapUiSizeCompact" role="application">
<div id="content"></div>
</body>
</html>

关于javascript - 如何将 XML View 传输到 JavaScript View /SAPUI5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50986101/

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