当前位置:K88软件开发文章中心编程全书微信小程序 → 文章内容

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

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-15 15:01:34

由 ?﹏???ζ???﹏﹏? 创建,Carrie 最后一次修改 2017-04-05 wx.openSetting(OBJECT) 基础库版本 1.1.0 开始支持,低版本需做兼容处理 调起客户端小程序设置界面,返回用户设置的操作结果Object 参数说明: 参数 类型 必填 说明 success Function 否 接口调用成功的回调函数,返回内容详见返回参数说明。 fail Function 否 接口调用失败的回调函数 complete Function 否 接口调用结束的回调函数(调用成功、失败都会执行) success返回参数说明: 参数 类型 说明 authSetting Object 用户授权结果,其中 key 为 scope 值,value 为 Bool 值,表示用户是否允许授权,详见 scope 列表 示例代码:wx.openSetting({ success: (res) => { /* * res.authSetting = { * "scope.userInfo": true, * "scope.userLocation": true * } */ }})OpenSettingButton wx.createOpenSettingButton(string type, string text, string image, Object style)支持版本 >= 2.0.7创建打开设置页面的按钮。参数string type按钮的类型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 调起客户端小程序设置界面