交互反饋:
wx.showToast({? ? 提示? 但會(huì)自動(dòng)下消失
title:"收藏成功"? 提示文字 可以卸載某個(gè)函數(shù)中
})
比如? onclick:function(){
wx.showToast({
title:"收藏成功"?
})
個(gè)人習(xí)慣 數(shù)組可以用s與單一分開(kāi)
如何吧收藏與取消收藏分開(kāi)
title:collection?"收藏成功":"取消收藏"
? ? ? ? ? ? ? ? 真? ? ? ? ? 假
}
duration:1500? ? 提示的延長(zhǎng)時(shí)間? 毫秒? 提示完之后會(huì)消失
icon:"success"? 默認(rèn)succees? 只有success 和loading? 兩種? 是一種圖標(biāo) 裝飾title
onclick:function(){
wx.showToast({
title:"收藏成功",
success:function(){
}?
})
wx.showMoadl({? ? 提示框 不會(huì)自動(dòng)消失
? ? ? title:"shoucang",
? ? ? content:"",
? ? ? showCancel:"true",
? ? ? cancelText:"bushoucang",
? ? ? cancelColor:"#333",
? ? ? confirmText:"shoucang",
? ? ? confirmColor:"#456",
})
onclick:function(){
wx.showActionSheet({
? itemList:[
? ? "分享給微信好友",
? ? "分享到朋友圈",
? ? "分享到QQ",
? ? "分享到微博"? ? ? ? ? ? 出現(xiàn)分享的列表
],
itemColor:"#ccc",? 字體顏色
? success:function(res){
? ? res.cancel 用戶是不是點(diǎn)擊了取消,
? ? res.tapIndex? 點(diǎn)擊的數(shù)組元素中的第幾個(gè)
})
? ? ? ? ? }
}
異步獲取緩存
get:function(){
var that=this;
wx.getStorage({
? key:"collected",
? success:function(res){? res 獲取的緩存的值
? ? ? var? collects=res.data;
? ? ? var? collect=collects[that.data.id]
}
})
}
音樂(lè)播放控制
onmusictap:function(event){
? ? var isPlayingMusic=this.data.isPlayingMusic;
? ? if(isPlayingMusic){
? ? ? wx.pauseBackgroundAudio();? ? 暫停
? this.setData({ isPlayingMusic:false})? ?
? ? ? ? ? ? ? ? ? ? ? }
? ? else{
? ? wx.playBackgroundAudio({
? ? dataUrl:"", 音樂(lè)鏈接
? ? title:"" ,標(biāo)題
? ? coverImgUrl:"",圖片鏈接
? ? })
? ? this.setData({
? ? isPlayingMusic:false;
? ? ? })
? ? }
}
判定變量是真假 可以另一種方法
src="{{isPlayingMusic? '/images/music/music-stop.png': '/images/music/music-start.png'}}"
音樂(lè)總開(kāi)關(guān) 與單個(gè)之間的同步
onload:
var thst=this
wx.onBackgroundAudioPlay(function(){
? that.setData({
? isPlayMusic:true
})
})
wx.onBackgroundAudioPause(function(){
? that.setData({
? isPlayMusic:false
})
})