# UserInfoButton wx.createUserInfoButton(Object object)
Start from base library version 2.0.1. Please remaining backward compatible.
Creates a user information button.
# Parameters
# Object object
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
type | string | Yes | The button type | |
text | string | No | The text on the button. It is valid only when type is text . | |
image | string | No | The background image of the button. It is valid only when type is image . | |
style | Object | Yes | The button style | |
withCredentials | boolean | Yes | Indicates whether to include login status information. When withCredentials is true, wx.login must be called previously and the login status must be effective. In this case, sensitive information such as encryptedData and iv is returned. When withCredentials is false, the login status is not required, and sensitive information such as encryptedData and iv is not returned. | |
lang | string | en | No | The language used to describe the user information |
Valid values of type
Value | Description | Minimum Version |
---|---|---|
text | A button that can be configured with background color and text | |
image | A button that can only be configured with background image. The background image is stretched to fit the button. |
style is composed as follows
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
left | number | Yes | The x-coordinate of the top-left corner | |
top | number | Yes | The y-coordinate of the top-left corner | |
width | number | Yes | Width | |
height | number | Yes | Height | |
backgroundColor | string | Yes | Background color | |
borderColor | string | Yes | The color of the border | |
borderWidth | number | Yes | The width of the border | |
borderRadius | number | Yes | The radius of the rounded corner on the border | |
textAlign | string | Yes | Text alignment method | |
fontSize | number | Yes | Font size | |
lineHeight | number | Yes | The line height of the text |
Valid values of style.textAlign
Value | Description | Minimum Version |
---|---|---|
left | Left | |
center | Center | |
right | Right |
Valid values of object.lang
Value | Description | Minimum Version |
---|---|---|
en | English | |
zh_CN | Simplified Chinese | |
zh_TW | Traditional Chinese |
# Return Values
# UserInfoButton
# Sample Code
let button = wx.createUserInfoButton({
type: 'text',
text: 'Get user information',
style: {
left: 10,
top: 76,
width: 200,
height: 40,
lineHeight: 40,
backgroundColor: '#ff0000',
color: '#ffffff',
textAlign: 'center',
fontSize: 16,
borderRadius: 4
}
})
button.onTap((res) => {
console.log(res)
})