收藏
回答

小程序能通过js改变配置pageOrientation值 使得屏幕强制横屏或者竖屏吗

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 工具 7.0.15 2.12.2

https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/page.html

回答关注问题邀请回答
收藏

3 个回答

  • Shoulder
    Shoulder
    2022-01-04


    注意:官方文档并没有列出此api。请谨慎考虑使用,建议跳转新页面json设置"pageOrientation""landscape"
    

      setPageOrientation: function(){

        var that = this;    

        wx.setPageOrientation({

          orientation: that.data.PageOrientation,  // landscape 横屏; portrait 竖屏

          complete: function(res){

            console.log(" 横屏回调 -- ",res);

            if(that.data.PageOrientation == "landscape"){

              that.data.PageOrientation = "portrait";

            }else{

              that.data.PageOrientation = "landscape";

            }

            

          }

        })

      },

    2022-01-04
    有用
    回复
  • Admin ²º²³
    Admin ²º²³
    2020-09-17

    目前是写死json里面的汗。

    没有办法通过js修改。

    2020-09-17
    有用
    回复
  • 微喵网络
    微喵网络
    2020-09-17

    不能

    2020-09-17
    有用
    回复
登录 后发表内容
问题标签