OpenSettingButton wx.createOpenSettingButton(Object object)

基础库 2.0.7 开始支持,低版本需做兼容处理

创建打开设置页面的按钮

参数

Object object

属性类型默认值必填说明
typestring按钮的类型。
textstring按钮上的文本,仅当 type 为 text 时有效
imagestring按钮的背景图片,仅当 type 为 image 时有效
styleObject按钮的样式

type 的合法值

说明最低版本
text可以设置背景色和文本的按钮
image只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高

style 的结构

属性类型默认值必填说明
leftnumber左上角横坐标
topnumber左上角纵坐标
widthnumber宽度
heightnumber高度
backgroundColorstring背景颜色
borderColorstring边框颜色
borderWidthnumber边框宽度
borderRadiusnumber边框圆角
colorstring文本的颜色。格式为 6 位 16 进制数。
textAlignstring文本的水平居中方式
fontSizenumber字号
lineHeightnumber文本的行高

style.textAlign 的合法值

说明最低版本
left居左
center居中
right居右

返回值

OpenSettingButton

示例代码

  1. let button = wx.createOpenSettingButton({
  2. type: 'text',
  3. text: '打开设置页面',
  4. style: {
  5. left: 10,
  6. top: 76,
  7. width: 200,
  8. height: 40,
  9. lineHeight: 40,
  10. backgroundColor: '#ff0000',
  11. color: '#ffffff',
  12. textAlign: 'center',
  13. fontSize: 16,
  14. borderRadius: 4
  15. }
  16. })