在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 微信小程序怎么實(shí)現(xiàn)局部刷新?

微信小程序怎么實(shí)現(xiàn)局部刷新?

我把評(píng)論放在一個(gè)list里,我想要實(shí)現(xiàn)點(diǎn)擊提交評(píng)論的時(shí)候新提交的內(nèi)容會(huì)出現(xiàn)在評(píng)論區(qū)

回答
編輯回答
尕筱澄

ajax提交,然后dom添加相應(yīng)的html

2017年12月16日 10:10
編輯回答
涼薄

js

page({
    data:{
      commitdata:[{user:"haha",content:"yo"},{user:"haha2",content:"yo2"}]
    }
    getData:function(){
        let that = this;
        wx.request({
            url:"xx.xx.xx",
            success:function(data){
                this.setData({commitdata:data});
            }
        })
    },
    commitData:function(){ //點(diǎn)擊提交數(shù)據(jù)
      let that = this;
        wx.request({
            url:"xx.xx.xx",
            success:function(data){ 
                this.setData({commitdata:that.commitdata.push(data)});
            }
        })
    }

})

wxml

<view wx:for="{commitdata}">{content}</view>

簡單的寫了下 大概就是這個(gè)樣子 提交后的數(shù)據(jù)push到原來的數(shù)據(jù)上面就行

2017年1月14日 11:27
編輯回答
局外人

獲取目前l(fā)ist內(nèi)容和新增評(píng)論的內(nèi)容,然后用concat的方法將評(píng)論內(nèi)容加入到list里,最后setData。

2017年6月24日 10:15