bluefox1688 / vue-cli-multi-page

因时间精力有限,项目已不再维护,请慎重使用,vue2-cli-vux2-multe-page,使用了webpack2+vuejs2+vuxUI2的多页面脚手架
829 stars 239 forks source link

ajax()怎么只能发get请求,不能发post请求呢? #46

Open ttflowerboys opened 7 years ago

ttflowerboys commented 7 years ago

发现在惊天大BUG:

ttflowerboys commented 7 years ago

image

import axios from 'axios';
var qs = require('qs');    // 新增 qs

function ajax(opt){

    var opts = opt || {};

    if (!opts.url) {
      alert('请填写接口地址');
      return false;
    }

    axios({
      method: opts.type || 'get',
      url: opts.url,
      params: opts.params || {},     // 这是路径的参数
      data: qs.stringify(opts.data),  // 这是post参数,并使用qs.stringify()处理数据
      headers: opts.headers || {
          'Content-Type':'application/x-www-form-urlencoded'
      },
      baseURL:'http://api.domain.com/api/',
      timeout: opts.time || 10*1000,
      responseType: opts.dataType || 'json'
    }).then()
bluefox1688 commented 7 years ago

确实会有个问题 需要重新配置一下 axios

ttflowerboys commented 7 years ago

我已经在你写的基础上改了,你看一下: aaaa

bluefox1688 commented 7 years ago

好,感谢