一、axios
引入 import axios from 'axios';使用 created(){axios.get("http://124.70.134.133:7001/api/movie/top250").then((res) => {this.tops = res.data.res});},
二、taro.request
可以引用taro使用taro发送http请求,使用方法与wx.request一致注意回调函数需要写成箭头函数去指向vc,否则this是undefined,因为是引用的taro
Taro.request({url: 'http://139.9.127.189:7000/api/movies/top250',method: 'GET',success: res=>{console.log(this);this.top250 = res.data.res;},fail: function(err) {console.log(err);},})
