原創(chuàng)聲明:本文為作者原創(chuàng),未經(jīng)允許不得轉(zhuǎn)載,經(jīng)授權(quán)轉(zhuǎn)載需注明作者和出處
最近在學(xué)習(xí)小程序與后端服務(wù)器(mysql)通訊,可是用下面的方法只能是被動(dòng)顯示。能不能給個(gè)立即顯示的代碼?謝謝。
<!--index.wxml-->
<view class="container">
<view bindtap="bindViewRead" >讀取數(shù)據(jù)</view>
<text>{{text}}</text>
</view>
//index.js
//讀取數(shù)據(jù)
bindViewRead: function() {
var page = this;
wx.request({
url: ‘https://localhost/mysql/read.php‘,
data: {
key: “asdf33rr”
},
header: {
‘content-type’: ‘a(chǎn)pplication/json’
},
success: function(res) {
page.setData({text:res.data});
console.log(res.data)
}
})
},
用上面的方法只能點(diǎn)“讀取數(shù)據(jù)”才有顯示,讓他無(wú)刷新顯示怎么做?