欧洲变态另类zozo,欧美xxxx做受欧美gaybdsm,欧洲熟妇色xxxx欧美老妇软件,免费人成视频xvideos入口 ,欧美.日韩.国产.中文字幕

歡迎光臨本站
我們一直在努力

微信小程序之點(diǎn)贊和刪除列表以及分享的功能實(shí)現(xiàn)

這篇文章主要介紹了微信小程序項(xiàng)目總結(jié)之點(diǎn)贊 刪除列表 分享功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下

小程序點(diǎn)贊功能

思路:在后臺沒有給你接口自己模擬數(shù)據(jù)

data:{ 
 likes:{ 
 iszan:false, 
 num:0 
} 
}
登錄后復(fù)制

1.遍歷評論列表 判斷點(diǎn)擊的id

2.如果id相同 判斷是否點(diǎn)贊過 如果為true -1 如果為false +1

3.更新數(shù)據(jù)

bindlike:function(e){ 
 var newData = this.data.release.map(function(item){ 
  if (item.id == e.currentTarget.dataset.id){ 
  console.log(item.id + e.currentTarget.dataset.id ) 
  if(item.likes.iszan){ 
   var obj = {} 
   obj.iszan = !item.likes.iszan; 
   obj.num = item.likes.num -1 ; 
   return Object.assign({},item,{likes:obj}) 
  }else { 
   var obj = {} 
   obj.iszan = !item.likes.iszan; 
   obj.num = item.likes.num + 1; 
   return Object.assign({}, item, { likes: obj }) 
  } 
  }else { 
  return item 
  } 
 }) 
 this.setData ({ 
  release:newData 
 }) 
 },
登錄后復(fù)制

2.點(diǎn)擊刪除列表功能

1.給撤銷按鈕綁定id 添加點(diǎn)擊事件

2.點(diǎn)擊刪除按鈕時提示是否刪除

3.如果用戶點(diǎn)擊確定 獲取到要刪除的id

4.刪除對應(yīng)的數(shù)組內(nèi)容

5.更新數(shù)據(jù)

//刪除評論 
 binddelete:function(e){ 
 var that = this; 
 wx.showModal({ 
  title: '提示', 
  content: '確認(rèn)撤回嗎?', 
 success:function(res){ 
  if(res.confirm){ 
 console.log('用戶點(diǎn)擊確定') 
 // 獲取要刪除數(shù)據(jù)的id 
 var dataid = e.currentTarget.dataset.id; 
 console.log(dataid) 
 // 刪除數(shù)組對應(yīng)的數(shù)據(jù)內(nèi)容 
 var release = that.data.release; 
 that.data.release.splice(dataid,1) 
 //判斷數(shù)據(jù)的長度 
 var len = that.data.release.length; 
 //通過判斷數(shù)組的長度來決定是否顯示隱藏的部分 
  that.setData ({ 
  release: that.data.release 
  }) 
  }else if(res.cancel){ 
  console.log('用戶點(diǎn)擊取消') 
  } 
 } 
 }) 
 },
登錄后復(fù)制

3.點(diǎn)擊分享

點(diǎn)擊分享按鈕 要給button按鈕綁定個 open-type =”share”屬性

通過給 button 組件設(shè)置屬性 open-type=”share”,可以在用戶點(diǎn)擊按鈕后觸發(fā) Page.onShareAppMessage() 事件,如果當(dāng)前頁面沒有定義此事件,則點(diǎn)擊后無效果。

Page({ 
 onShareAppMessage: function (res) { 
 if (res.from === 'button') { 
 // 來自頁面內(nèi)轉(zhuǎn)發(fā)按鈕 
 console.log(res.target) 
 } 
 return { 
 title: '自定義轉(zhuǎn)發(fā)標(biāo)題', 
 path: '/page/user?id=123' 
 } 
 } 
})
登錄后復(fù)制

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,更多相關(guān)內(nèi)容請關(guān)注PHP中文網(wǎng)!

相關(guān)推薦:

以上就是微信小程序之點(diǎn)贊和刪除列表以及分享的功能實(shí)現(xiàn)的詳細(xì)內(nèi)容,更多請關(guān)注有卡有網(wǎng)。

版權(quán)聲明:本文采用知識共享 署名4.0國際許可協(xié)議 [BY-NC-SA] 進(jìn)行授權(quán)
文章名稱:《微信小程序之點(diǎn)贊和刪除列表以及分享的功能實(shí)現(xiàn)》
文章鏈接:http://www.ljxxtl.cn/kaquan-baike/xcx/154631.html
本站資源僅供個人學(xué)習(xí)交流,請于下載后24小時內(nèi)刪除,不允許用于商業(yè)用途,否則法律問題自行承擔(dān)。