美文网首页
axios form data

axios form data

作者: yzc123446 | 来源:发表于2017-08-25 14:33 被阅读257次
    image.png
    var form={
    "sl": "en",
    "tl": "zh-CN",
    "p": "1",
    "q": "A test text."
    }
    axios({
    method: 'post',
    url: 'http://www.tastemylife.com/gtr.php',
    data: form,
    headers: {
    'content-type': 'application/x-www-form-urlencoded'
    },
    transformRequest: [function (data) {
    // Do whatever you want to transform the data
    let ret = ''
    for (let it in data) {
    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
    }
    return ret
    }],
    })
    .then(function (res) {
    _this.title[Object.keys(_this.title)[1]] = res.result
    return resolve(res);
    })
    .catch(function (err) {
    console.log(err);
    })

    或者jQuery param() 方法

    相关文章

      网友评论

          本文标题:axios form data

          本文链接:https://www.haomeiwen.com/subject/eyvudxtx.html