所有浏览器在VueJS PWA上的锁定方向(纵向)

我正在尝试获取屏幕锁以用于我的Web应用程序。 我一直在搜索论坛,但找不到解决此问题的方法。

有人知道我如何解决这个问题吗?

tfdghdfsersffy 回答:所有浏览器在VueJS PWA上的锁定方向(纵向)

我使用scss媒体查询来解决此问题。

@media screen and (min-aspect-ratio: 13/9) {
  html {
    transform: rotate(-90deg);
    transform-origin: left top;
    width: 100vh;
    overflow-x: hidden;
    position: absolute;
    top: 100%;
    left: 0;
  }
  .bw-dashboard {
    height: inherit;
  }
}
@media screen and (min-width: 1292px) {
  html {
    transform: none;
    transform-origin: none;
    width: 100%;
    overflow-x: none;
    position: relative;
  }
  .bw-dashboard {
    height: 100vh;
  }
}
,

当前PWA尚没有一个整体可行的解决方案,我认为CSS方法并不十分令人满意。

但是您可以使用ScreenOrientation API,该版本适用于除Safari和Edge(移动设备/桌面)以外的所有浏览器。 请勿使用过时的Screen API

如果您打算将PWA包装到移动应用程序中,CapacitorCordova之类的框架将提供本机桥接器,以访问相应的方向锁定功能。

本文链接:https://www.f2er.com/3151152.html

大家都在问