如何在ios移动应用程序中显示注销警报框



我正在使用phonegap运行它。当我在Android中运行时,注销框是正确的,并且在注销框中显示"确认"作为标题。即使在ios中,一切都很完美,但注销框将标题显示为"index.html"(这是当前页面名称(

$rootScope.logout=function()
{
response=confirm(GetLocalString("HMLOGOUTMSG",_language));
if(response==true)
{
logout();
}
else
{
menuchk();
}
}

我不希望标题为"索引.html"。您能否建议一种不将标题显示为"索引.html的方法

在ios PhoneGap页面中将显示警报中的页面名称,您需要使用插件进行通知。 要添加插件,请运行此代码。

cordova plugin add cordova-plugin-dialogs

用法

navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
消息
  • :对话框消息。(字符串(
  • confirmCallback:按下按钮索引 (1, 2 或 3( 或对话框在没有按按钮的情况下关闭 (0( 时。 (功能(
  • 标题
  • :对话框标题。(字符串((可选,默认为确认(
  • 按钮标签
  • :指定按钮标签的字符串数组。(阵列( (可选,默认为 [确定,取消](

function onConfirm(buttonIndex) {
alert('You selected button ' + buttonIndex);
}
navigator.notification.confirm(
'You are the winner!', // message
onConfirm,            // callback to invoke with index of button pressed
'Game Over',           // title
['Restart','Exit']     // buttonLabels
);

回调采用参数 buttonIndex (Number(,它是按下按钮的索引。请注意,索引使用从 1 开始的索引,因此值为 1、2、3 等。

文档

现在它工作正常,

$rootScope.logout = function () {
function onConfirm(buttonIndex) {
if (buttonIndex == 1) {
logoutfunc();
}
else {
menuopenchk();
}
}
navigator.notification.confirm(
'Are you sure to logout?',
onConfirm,
'Logout',
['Yes', 'Not Now']
);
}

最新更新