自学内容网 自学内容网

Uniapp 打包后的横屏控制

文章目录


问题

Uniapp 打包后的横竖屏跟开发模式不太一样,需要在代码里设置一下

处理

需要改两个地方

  • pages.json:在 globalStyle 中添加 "pageOrientation": "auto",
    在这里插入图片描述

  • manifest.json:在第一层后面添加 orientation
    在这里插入图片描述

    // pages.json
    "pageOrientation": "auto",
    
    // manifest.json
    "orientation" : [ "landscape-primary", "landscape-secondary" ]
    
    // orientation 有如下的可选项,我只需要横屏,所以上面只写了两个
    "orientation" : [
    //竖屏正方向
    "portrait-primary",
    //竖屏反方向
    "portrait-secondary",
    //横屏正方向
    "landscape-primary",
    //横屏反方向
    "landscape-secondary",
    //自然方向
    "default"
    ]
    

参考

  1. 具体参考官网的这个页面 https://en.uniapp.dcloud.io/collocation/manifest.html#app-plus
    在这里插入图片描述
  2. 博客

原文地址:https://blog.csdn.net/u010263423/article/details/142482910

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!