sap.m.MessageBox.confirm 工作 sap.m.MessageBox.error 或 sap.m.MessageBox.warning 不工作
sap.m.MessageBox.confirm working sap.m.MessageBox.error or sap.m.MessageBox.warning not working
在我的 sapui5 项目中,我使用 sap.m.MessageBox.confirm
它工作正常但是当我使用 sap.m.MessageBox.error
或 sap.m.MessageBox.warning
时它显示错误
Uncaught TypeError: undefined is not a function
我已经添加了jQuery.sap.require("sap.m.MessageBox");
问题还是没有解决。请给出这个问题的解决方案
谢谢
抱歉没有早点发布代码
已编辑 1
查看
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="trial.S1" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Title">
<content>
</content>
<footer>
<OverflowToolbar>
<ToolbarSpacer />
<Button id="errorId" text="Error" type="Accept"
press="fnOnerror" />
<Button id="confirmId" text="Confirm" type="Accept"
press="fnOnconfirm" />
</OverflowToolbar>
</footer>
</Page>
</core:View>
控制器
jQuery.sap.require("sap.m.MessageBox");
sap.ui.controller("trial.S1", {
fnOnerror : function(oEvent){
sap.m.MessageBox.error("My error message");
},
fnOnconfirm : function(oEvent){
sap.m.MessageBox.confirm("My Confirm message")
}
});
index.html
<!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="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
sap.ui.localResources("trial");
var app = new sap.m.App({initialPage:"idS11"});
var page = sap.ui.view({id:"idS11", viewName:"trial.S1", type:sap.ui.core.mvc.ViewType.XML});
app.addPage(page);
app.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
如果您的信息不充分,我们应该如何为您解决问题?根据您的描述,很难判断您做错了什么。确保始终添加更多信息,包括代码。
从您那里得到信息后,我们现在知道您使用的是 1.28.9 版本的 UI5。如果您查看了 https://openui5.hana.ondemand.com/#docs/api/symbols/sap.m.MessageBox.html#.error 的 API 文档,那么您就会知道您使用的 API 是在 1.30 中引入的!!!
在我的 sapui5 项目中,我使用 sap.m.MessageBox.confirm
它工作正常但是当我使用 sap.m.MessageBox.error
或 sap.m.MessageBox.warning
时它显示错误
Uncaught TypeError: undefined is not a function
我已经添加了jQuery.sap.require("sap.m.MessageBox");
问题还是没有解决。请给出这个问题的解决方案
谢谢
抱歉没有早点发布代码
已编辑 1
查看
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="trial.S1" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Title">
<content>
</content>
<footer>
<OverflowToolbar>
<ToolbarSpacer />
<Button id="errorId" text="Error" type="Accept"
press="fnOnerror" />
<Button id="confirmId" text="Confirm" type="Accept"
press="fnOnconfirm" />
</OverflowToolbar>
</footer>
</Page>
</core:View>
控制器
jQuery.sap.require("sap.m.MessageBox");
sap.ui.controller("trial.S1", {
fnOnerror : function(oEvent){
sap.m.MessageBox.error("My error message");
},
fnOnconfirm : function(oEvent){
sap.m.MessageBox.confirm("My Confirm message")
}
});
index.html
<!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="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
sap.ui.localResources("trial");
var app = new sap.m.App({initialPage:"idS11"});
var page = sap.ui.view({id:"idS11", viewName:"trial.S1", type:sap.ui.core.mvc.ViewType.XML});
app.addPage(page);
app.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
如果您的信息不充分,我们应该如何为您解决问题?根据您的描述,很难判断您做错了什么。确保始终添加更多信息,包括代码。
从您那里得到信息后,我们现在知道您使用的是 1.28.9 版本的 UI5。如果您查看了 https://openui5.hana.ondemand.com/#docs/api/symbols/sap.m.MessageBox.html#.error 的 API 文档,那么您就会知道您使用的 API 是在 1.30 中引入的!!!