javascript SAPUI5 在视图中创建 HTML 内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24955069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SAPUI5 create HTML content in a view
提问by vincent T
I am really new with SAPUI5 and I am just trying to make a web interface with 2 pages.
我对 SAPUI5 真的很陌生,我只是想用 2 页制作一个 Web 界面。
If you're familiar with angularjs, I would like to reproduce what we can do with the ng-viewelement.
如果您熟悉 angularjs,我想重现我们可以用ng-view元素做什么。
So, how do I integrate the html code to my view?
那么,如何将 html 代码集成到我的视图中?
Here is the code of my actual view:
这是我的实际视图的代码:
sap.ui.jsview("delaware_pimonitor.Dashboard", {
getControllerName : function() {
return "delaware_pimonitor.Dashboard";
},
createContent : function(oController) {
var aControls = [];
var oButton = new sap.ui.commons.Button({
id : this.createId("MyButton2"),
text : "Mubutton2"
});
aControls.push(oButton);
return aControls;
}
});
The examples on internet always show me how to create a button, but that's all...
互联网上的例子总是向我展示如何创建一个按钮,但仅此而已......
采纳答案by vincent T
ANSWER HERE
在这里回答
Here is the answer: SHELL - https://sapui5.netweaver.ondemand.com/sdk/#test-resources/sap/ui/ux3/demokit/Shell.html
这是答案:SHELL - https://sapui5.netweaver.ondemand.com/sdk/#test-resources/sap/ui/ux3/demokit/Shell.html
This allows you to create a panel and add pages or whatever you want inside it. It is basically to make a top menu with each page of the website.
这允许您创建一个面板并在其中添加页面或任何您想要的内容。基本上是为网站的每个页面制作一个顶部菜单。
The demo in the last link, don't give all the code source.
最后一个链接里的demo,不要给出所有的代码源。
So here is the all code, which is actually working now:http://jsbin.com/duwoqova/1/edit
所以这里是所有代码,它现在实际上正在工作:http : //jsbin.com/duwoqova/1/edit
Thanks again
再次感谢
回答by Roshan
It is better if you don't use HTML code in sapui5(except for just making some div and appending some controls in it).Do all view related thing in your view. Make a layout in view and put all the controls under that layout and finalLy return it or append in div that you have created in index.html.As for example
如果您不在 sapui5 中使用 HTML 代码会更好(除了只是制作一些 div 并在其中附加一些控件)。在您的视图中执行所有与视图相关的事情。在视图中创建一个布局并将所有控件放在该布局下并最终返回它或附加到您在 index.html 中创建的 div 中。例如
sap.ui.jsview("delaware_pimonitor.Dashboard", {
getControllerName : function() {
return "delaware_pimonitor.Dashboard";
},
createContent : function(oController) {
var aControls = [];
var oButton = new sap.ui.commons.Button({
id : this.createId("MyButton2"),
text : "Mubutton2"
});
aControls.push(oButton);
return aControls// or append to div using .placeAt("your div id");
}
});