微信小程序API 调起客户端小程序设置界面


当前第2页 返回上一页

type 的合法值:

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

string text

按钮上的文本,仅当 type 为 text 时有效

string image

按钮的背景图片,仅当 type 为 image 时有效

Object style

按钮的样式

属性 类型 默认值 是否必填 说明 支持版本
left number 左上角横坐标
top number 左上角纵坐标
width number 宽度
height number 高度
backgroundColor string 背景颜色
borderColor string 边框颜色
borderWidth number 边框宽度
borderRadius number 边框圆角
textAlign string 文本的水平居中方式
fontSize number 字号
lineHeight number 文本的行高

style.textAlign 的合法值:

说明
left 居左
center 居中
right 居右

返回值

OpenSettingButton

示例代码

let button = wx.createOpenSettingButton({
    type: 'text',
    text: '打开设置页面',
    style: {
        left: 10,
        top: 76,
        width: 200,
        height: 40,
        lineHeight: 40,
        backgroundColor: '#ff0000',
        color: '#ffffff',
        textAlign: 'center',
        fontSize: 16,
        borderRadius: 4
    }
})

wx.getSetting(OBJECT)


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

获取用户的当前设置

Object 参数说明:

参数 类型 必填 说明
success Function 接口调用成功的回调函数,返回内容详见返回参数说明。
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明:

参数 类型 说明
authSetting Object 用户授权结果,其中 key 为 scope 值,value 为 Bool 值,表示用户是否允许授权,详见 scope 列表

示例代码:

wx.getSetting({
  success: (res) => {
    /*
     * res.authSetting = {
     *   "scope.userInfo": true,
     *   "scope.userLocation": true
     * }
     */
  }
})



标签:微信小程序

返回前面的内容

相关阅读 >>

微信小程序api 数据分析

微信小程序 数据分析

微信小程序 weuicheckbox-group

微信小程序 send

微信小程序框架逻辑层(app service)

sdk数据库 command聚合操作符对象操作符

微信小程序云开发 第一个云开发小程序

微信小程序云开发 api数据库更新记录

微信小程序云开发 兼容性问题

微信小程序 add

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...