通过api旋转屏幕 wx.setPageOrientation

发布于 4 年前作者 qiuxiuying1498 次浏览最后编辑 4 年前来自 share

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。请酌情考虑是否用于生产

0 回复
暂无回复