集成uinapp一些使用方法,说不定就有你需要的
1.隐藏状态栏。
我是在全局也就是App.vue文件onLaunch方法中添加如下代码即可实现。
plus.navigator.setFullscreen(true);
参考:https://www.jianshu.com/p/7344c4066e82
2.强制横屏--安卓
全局App.vue文件onLaunch方法中添加如下代码即可实现。
plus.screen.lockOrientation( 'landscape-secondary');
plus.screen.lockOrientation( 'landscape-primary');
参考:https://ask.dcloud.net.cn/question/63949
3.获取当前页面路由以及参数
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 let curRoute = routes[routes.length - 1].route //获取当前页面路由 let curParam = routes[routes.length - 1].options; //获取路由参数
参考:https://blog.csdn.net/qq_31754523/article/details/106859938
4.判断长时间不操作界面
需求说明,后台有做半个小时不请求接口的话返回标识退出登录,但是要请求接口才行,现在要实现前端用js判断半个小时不操作界面的话自动跳转到登录页面。
创建一个.js文件,在main.js引入此js(vue框架)
在登录成功的时候保存当前时间localStorage.setItem("lastTime",new Date().getTime());
然后在点击的时候更新这个时间
var lastTime = new Date().getTime(); var currentTime = new Date().getTime(); var timeOut = 30 * 60 * 1000; //设置超时时间: 30分 window.onload = function () { window.document.onmousedown = function () { localStorage.setItem("lastTime",new Date().getTime()); } }; function checkTimeout() { currentTime = new Date().getTime(); //更新当前时间 lastTime = localStorage.getItem("lastTime"); // console.log(currentTime - lastTime); // console.log(timeOut); if (currentTime - lastTime > timeOut) { //判断是否超时 // console.log("超时"); var url = window.location.href; var newUrl=url.match(/(\S*)#/)[1]; window.open(newUrl + '#/login','_self'); } } /* 定时器 间隔30秒检测是否长时间未操作页面 */ window.setInterval(checkTimeout, 30000);
参考:https://freexyz.cn/dev/25064.html
5.解决uinapp swiper在web端手动滑动不顺滑卡顿问题。
在swiper-item内容区域增加一个遮罩层,问题是因为内容区域是图片导致。手动滑动会先移动图片,导致卡顿不顺畅问题。
html
<swiper class="swiper-body" :autoplay="false" :circular="true" @change="slidChange" :current-item-id="tabActive"> <swiper-item class="swiper-item" v-for="(item,index) in bannerList" :key="index" :item-id='item.filePath'> <image class="swiper-content" :src="item.filePath"></image> <!-- mask解决在web端轮播手动切换问题。 --> <view class="swiper-content-mask"></view> </swiper-item>
</swiper>
css
.swiper-body { width 100%; height 79.53757%; position relative; .swiper-item,.swiper-content { width 100%; height 100%; } .swiper-content-mask {//mask解决在web端轮播手动切换问题。 position absolute; top 0; right 0; bottom 0; left 0; } }

浙公网安备 33010602011771号