1、安装插件
Toast is compatible with Cordova Plugman, compatible with PhoneGap 3.0 CLI, here's how it works with the CLI (backup your project first!):
Using the Cordova CLI and the Cordova Plugin Registry
$ cordova plugin add nl.x-services.plugins.toast $ cordova prepare
Or using the phonegap CLI
$ phonegap local plugin add nl.x-services.plugins.toast
Or
$ cordova plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
安装后可以用命令查看 http://www.cnblogs.com/cuoreqzt/p/4491943.html
2、在app中加上js
.run(function ($ionicPlatform, $rootScope, $location, $timeout, $ionicHistory, $ionicPopup, $cordovaToast) { $ionicPlatform.ready(function () { // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); } if (window.StatusBar) { // org.apache.cordova.statusbar required StatusBar.styleLightContent(); } //双击退出 $ionicPlatform.registerBackButtonAction(function (e) { function showConfirm() { var confirmPopup = $ionicPopup.confirm({ title: '<strong>退出应用?</strong>', template: '你确定要退出应用吗?', okText: '退出', cancelText: '取消' }); confirmPopup.then(function (res) { if (res) { ionic.Platform.exitApp(); } else { // Don't close } }); } //判断处于哪个页面时双击退出 if ($location.path() == '/home' ) { showConfirm(); } else if ($ionicHistory.backView() ) { $ionicHistory.goBack(); } else { // This is the last page: Show confirmation popup showConfirm(); } e.preventDefault(); return false; }, 101); }); })
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步