1.Toast
handleShowToast(){
wx.showToast({
title: '你好啊',
duration:3000,
icon:'none',
mask:true,
success(){
console.log('展示弹窗成功');
},
fail(){
console.log('展示弹窗失败');
},
complete(){
console.log("完成函数的调用");
}
})
},
2.modal
<!-- modal -->
<button bindtap="handleShowModal">ShowModal</button>
handleShowModal(){
wx.showModal({
title:'确定退出吗',
content:"我是内容 hahah ",
cancelColor: 'red',
confirmColor:'#58bc58',
success(res){
// console.log(res);
if(res.cancel){
console.log("取消");
}
if(res.confirm){
console.log("确定");
}
},
showCancel:true,
cancelText:"退出"
})
},
3.loading
<!-- loading -->
<button bindtap="handleShowLoading">ShowLoading</button>
handleShowLoading(){
wx.showLoading({
title: '加载中',
mask: true,
success: (res) => {},
fail: (res) => {},
complete: (res) => {},
})
setTimeout(()=>{
// 必须手动调用hideLoading才会消失
wx.hideLoading()
},2000)
},
4.actionSheet
<!-- actionSheet -->
<button bindtap="handleShowActionSheet">actionSheet</button>
handleShowActionSheet(){
wx.showActionSheet({
itemList: ['相册','拍照'],
itemColor:'red',
success(res){
console.log(res);
},
fail(err){
console.log(err);
}
})
},
5.分享
第一直接按按钮
<!-- 分享按钮 -->
<button open-type="share">分享</button>
第二按右上角
onShareAppMessage: function () {
return {
title:"小程序aaa",
path:"pages/index/index",
imageUrl:'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
}
}