当前位置 : 主页 > 网络编程 > JavaScript >

ajax 请求方式

来源:互联网 收集:自由互联 发布时间:2021-06-30
gistfile1.txt // getlet url = this.initGetUrl(host, this.url) this.$http.get(url, { params: { hb_key: this.hb_key } }).then((response) = { // Lambda写法 response = response.data; if (response.code == 10000){ this.jiaoyier = response.data.
gistfile1.txt
// get
let url = this.initGetUrl(host, this.url)

    this.$http.get(url,  {
      params: {
        hb_key: this.hb_key
      }
    }).then((response) => {  // Lambda写法
      response = response.data;
      if (response.code == 10000){
        this.jiaoyier = response.data.zu_money
        this.forRmb = response.data.total_shouyu
        this.allyonghu = response.data.number
      }
    });
// 方法二
let url = this.getNewListUrl +'?event_key='+this.event_key

this.$http.get(url).then((response) => {
  response = response.data;
  console.log(response)
  if (response.code == 10000){
    this.dataShuj = response.data.rank_list
    // 滚动ios兼容性
    let rillWidth =  $(".rolling_list li").eq(0).width()*$(".rolling_list li").length+($(".rolling_list li").length-1)*50
    $(".rolling_list").css('width', rillWidth + 'px');
  }

// post
import qs from 'qs';
var params2 = {
    tel: this.telVal,
    event_key: this.event_key,
    money: this.money,
    hb_type: hb_type
}
this.$http.post(this.addItemsUrl, qs.stringify(params2)).then((response) => {
  response = response.data;
//                console.log(response)
  if(response.code = 10000) {
    window.location.href = './success.html?telVal='+this.telVal+'&money='+ this.money
  }
})
网友评论