apicloud 双击返回键退出应用(源码分享)

  1. 在源码注释位置,修改为您的 widget id
  2. 代码粘贴在 apiready 函数中;
/* 是否退出 */
window.isExit=false;
/*监听返回键事件*/
api.addEventListener({
    name: 'keyback'
}, function(ret, err) {
  if(window.isExit){
    api.closeWidget({
      id: '你的APPID',    //在项目根目录 config.xml 的 <widget> 标记 的 id 属性
      silent : true
    });
  }else {
    api.toast({
        msg: '再按一次退出应用',
        duration: 1000,
        location: 'bottom'
    });

    window.isExit=true;
    setTimeout(function(){
      window.isExit=false;
    },1000);
  }
});

作者:黄河爱浪 QQ:1846492969,邮箱:[email protected]

微信公众号:web-7258,本文原创,著作权归作者所有,转载请注明原链接及出处。

更多精彩文章,请扫下方二维码关注我的公众号

发布了112 篇原创文章 · 获赞 24 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/u013350495/article/details/94328202