在pages. json中
全局在globalStyle添加"pageOrientation": "auto"
单个页面在单个页面的配置style下添加如下
"mp-weixin": {
"pageOrientation": "auto"
},
单个页面vue中添加如下
onShow(){
// 0为竖屏,1为横屏
let lastState = 0;
let lastTime = Date.now();
wx.startAccelerometer();
wx.onAccelerometerChange((res) => {
// console.log('onAccelerometerChange执行了')
const now = Date.now();
// 500ms检测一次 500ms实测可能会导致页面的onResize先执行了,
if (now - lastTime <