html52.com
我爱小程序-开发者交流社区

点击button重新请求数据如何实现?

问题模块
API和组件

改变URl重新获取数据如何实现?

 wx.request({
      url: '',
      data: {},
      method: 'GET',
      header: {      
        'content-type': 'application/json'
              }, // 设置请求的 header
      success: function(res){
        that.setData({
         servicePrice:res.data.result
        })  
      },
      fail: function() {
      },
      complete: function() {
      }
    })


是否通过this.setdata?




网友回复

致我的奋斗:
var that = this;
wx.request({
      url: '',
      data: {},
      method: 'GET',
      header: {     
        'content-type': 'application/json'
              }, // 设置请求的 header
      success: function(res){
        that.setData({
         servicePrice:res.data.result
        }) 
      },
      fail: function() {
      },
      complete: function() {
      }
    })

你的servicePrice应该在Page里面的data中对应,这样就可以在WXML中实现动态绑定

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付