我正在使用 phonegap 运行它。当我在 Android 中运行时,注销框是正确的,并且在注销框中显示“确认”作为标题。即使在 ios 中,一切都很完美,但注销框显示标题为“index.html”(这是当前页面名称)
$rootScope.logout=function()
{
response=confirm(GetLocalString("HMLOGOUTMSG",_language));
if(response==true)
{
logout();
}
else
{
menuchk();
}
}
我不希望标题为“index.html”。你能建议一种不将标题显示为“index.html”的方法
最佳答案
在ios中PhoneGap页面会在alert中显示页面名称,需要使用插件进行通知。 要添加插件,请运行此代码。
cordova plugin add cordova-plugin-dialogs
用法
navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
- message:对话消息。 (字符串)
- confirmCallback:在按下按钮索引时调用的回调 (1, 2 或 3) 或在没有按下按钮的情况下关闭对话框时 (0)。 (功能)
- title:对话框标题。 (字符串)(可选,默认为确认)
- buttonLabels:指定按钮标签的字符串数组。 (大批) (可选,默认为[确定,取消])
例子
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、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']
);
}
关于android - 如何在 iOS 移动应用程序中显示注销警告框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45433713/