title: Taro.setBackgroundColor(option)
sidebar_label: setBackgroundColor
Dynamically sets the background color of the window.
Type
(option: Option) => Promise<CallbackResult>
Parameters
Option
Property | Type | Required | Description |
---|---|---|---|
backgroundColor | string |
No | The background color of the window, which must be a hexadecimal value |
backgroundColorBottom | string |
No | The background color of the bottom window (only for iOS), which must be a hexadecimal value |
backgroundColorTop | string |
No | The background color of the top window (only for iOS), which must be a hexadecimal value |
complete | (res: CallbackResult) => void |
No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail | (res: CallbackResult) => void |
No | The callback function for a failed API call |
success | (res: CallbackResult) => void |
No | The callback function for a successful API call |
Sample Code
Taro.setBackgroundColor({
backgroundColor: '#ffffff', // The background color of the window is white.
})
Taro.setBackgroundColor({
backgroundColorTop: '#ffffff', // The background color of the top window is white.
backgroundColorBottom: '#ffffff', // The background color of the bottom window is white.
})
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.setBackgroundColor | ✔️ | ✔️(Only Android) |