微信小程序api视频课程-网络-wx.request 请求简单的字符串数据的使用

版权声明:黄菊华 https://blog.csdn.net/u013818205/article/details/88656304

默认效果
在这里插入图片描述
点击按钮后获取数据
在这里插入图片描述

wxml代码

<button bindtap="zfc">获取远程字符串数据</button>

返回数据:{{jieguo}}

js代码

/**
   * 页面的初始数据
   */
  data: {
    jieguo:""
  },
  zfc:function(){
    var that=this;
    wx.request({
      url: 'http://www.hzyaoyi.cn/shuju/01-string.asp',
      success:function(res){
        console.log(res.data)
        that.setData({
          jieguo: res.data
        })
      }
    })
  },

欢迎大家收看我的视频教程:微信小程序常用API使用
https://edu.csdn.net/course/detail/16194
网络-wx.request 请求简单的字符串数据

猜你喜欢

转载自blog.csdn.net/u013818205/article/details/88656304