Skip to main content
Version: 3.x

Taro.setKeepScreenOn(option)

Sets whether to keep the screen always bright. This setting only works in the current Mini Program.

Reference

Type

(option: Option) => Promise<Promised>

Parameters

Promised

PropertyTypeDescription
errMsgstringCall result

Option

PropertyTypeRequiredDescription
keepScreenOnbooleanYesIndicates whether to keep the screen always bright
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

Sample Code

Taro.setKeepScreenOn({
keepScreenOn: true
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.setKeepScreenOn✔️✔️