title: Taro.setKeepScreenOn(option)

sidebar_label: setKeepScreenOn

设置是否保持常亮状态。仅在当前小程序生效,离开小程序后设置失效。

支持情况:setKeepScreenOn - 图1 setKeepScreenOn - 图2 setKeepScreenOn - 图3

参考文档

类型

  1. (option: Option) => Promise<Promised>

参数

参数 类型
option Option

Promised

参数 类型 说明
errMsg string 调用结果

Option

参数 类型 必填 说明
keepScreenOn boolean 是否保持屏幕常亮
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
success (res: TaroGeneral.CallbackResult) => void 接口调用成功的回调函数

示例代码

  1. // 保持屏幕常亮
  2. Taro.setKeepScreenOn({
  3. keepScreenOn: true
  4. })