需求: 需要在第一次安装后第一次启动加载一个弹窗效果
h5写的app需要在 入口文件index.html中写入以下代码:
// 在js判断localStorage中是否第一次登录 var fristFlag=localStorage.getItem("fristFlag"); //判断fristFlag是否有值,如果为null,则没有值,进入判断,进行弹窗;如果为true,则不仅如此判断 if(fristFlag==null){//弹窗确定为true,取消为falsevar p=confirm("内容")//判断是否为true,为true,则进入app首页if(p){//将fristFlag设置为true,代表不是第一次登录localStorage.setItem("fristFlag",true);//跳转首页windows.localtion.href='路径'}else{//退出app plus为h5+内置api,具体可看文档链接https://www.html5plus.org/doc/zh_cn/runtime.html//quit()退出应用plus.runtime.quit();} }
javascript
运行
1234567891011121314151617181920