/* ---page/test/test.wxml----*/<button bindtap="binToast">toast<button/>/* ---page/test/test.wxml----*/ |
/* ---page/test/test.js----*/Page({ binToast:function(){ wx.showToast({ title: ‘成功‘, icon: ‘success‘, duration: 2000 }) },})/* ---page/test/test.js----*/ |
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| title | String | 是 | 提示的内容 |
| icon | String | 否 | 图标,只支持"success"、"loading" |
| duration | Number | 否 | 提示的延迟时间,单位毫秒,默认:1500, 最大为10000 |
| success | Function | 否 | 接口调用成功的回调函数 |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
/* ---page/test/test.wxml----*/<button bindtap="binLoading">binLoading<button/>/* ---page/test/test.wxml----*/ |
/* ---page/test/test.js----*/Page({ binLoading:function(){ wx.showToast({ title: ‘加载中‘, icon: ‘loading‘, duration: 10000 }) setTimeout(function(){ wx.hideToast() },2000) },})/* ---page/test/test.js----*/ |
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| title | String | 是 | 提示的标题 |
| content | String | 是 | 提示的内容 |
| showCancel | Boolean | 否 | 是否显示取消按钮,默认为 true |
| cancelText | String | 否 | 取消按钮的文字,默认为"取消",最多 4 个字符 |
| cancelColor | HexColor | 否 | 取消按钮的文字颜色,默认为"#000000" |
| confirmText | String | 否 | 确定按钮的文字,默认为"确定",最多 4 个字符 |
| confirmColor | HexColor | 否 | 确定按钮的文字颜色,默认为"#3CC51F" |
| success | Function | 否 | 接口调用成功的回调函数,返回res.confirm为true时,表示用户点击确定按钮 |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
/* ---page/test/test.wxml----*/<button bindtap="bindModal">Modal<button/>/* ---page/test/test.wxml----*/ |
/* ---page/test/test.js----*/Page({ bindModal:function(){ wx.showModal({ title: ‘提示‘, content: ‘这是一个模态弹窗‘, success: function(res) { if (res.confirm) { console.log(‘用户点击确定‘) } } }) },})/* ---page/test/test.js----*/ |
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| itemList | String Array | 是 | 按钮的文字数组,数组长度最大为6个 |
| itemColor | HexColor | 否 | 按钮的文字颜色,默认为"#000000" |
| success | Function | 否 | 接口调用成功的回调函数,详见返回参数说明 |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
/* ---page/test/test.wxml----*/<button bindtap="bindActionSheet">ActionSheet<button/>/* ---page/test/test.wxml----*/ |
/* ---page/test/test.js----*/Page({ bindActionSheet:function(){ wx.showActionSheet({ itemList: [‘A‘, ‘B‘, ‘C‘], success: function(res) { if (!res.cancel) { console.log(res.tapIndex) } } }) },})/* ---page/test/test.js----*/ |
原文:http://www.cnblogs.com/dandingjun/p/6088226.html