通过api旋转屏幕 wx.setPageOrientation
发布于 2 年前 作者 qiuxiuying 812 次浏览 来自 分享

wx.setPageOrientation(Object object)

基础库 2.10.4 及以上支持

设置屏幕方向

参数
Object object

属性 类型 默认值 必填 说明
orientation string landscape 横屏 portrait 竖屏
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码
在开发者工具中预览效果


wx.setPageOrientation ({ orientation: 'landscape', complete: console.log } )

效果展示

Bug & Tip

  1. tip: PC端暂不支持 返回 errMsg: "setPageOrientation:fail:not supported"

注意
官方文档并没有列出此api。请酌情考虑是否用于生产

回到顶部