screen.orientation.lock() 在此设备上不可用

问题描述 投票:0回答:0

使用此代码:

screen.orientation.lock('portrait');

在桌面版 Chrome 中出现此错误:

screen.orientation.lock() is not available on this device.

如何通过在调用之前检查 .lock() 是否可用来避免丑陋的错误?

这个问题的答案对我不起作用。

javascript screen-orientation feature-detection
© www.soinside.com 2019 - 2024. All rights reserved.