[精讚] [會員登入]
1068

axios vuejs application/x-www-form-urlencoded 送資料

VUE.JS 以 application/x-www-form-urlencoded 送資料

分享此文連結 //n.sfs.tw/11468

分享連結 axios vuejs application/x-www-form-urlencoded 送資料 @igogo
(文章歡迎轉載,務必尊重版權註明連結來源)
2019-10-25 13:09:42 最後編修
2017-07-19 00:23:08 By igogo
 

結論: 只有chrome 適用 , 我還是默默的用json 傳值

 

如圖, vue.js+axios 送出json 的物件很簡單, 但是如果想送的是像form action submit的資料時要怎麼做呢

 

Vue.prototype.$http = axios;
    var config = {
        headers: {
        'content-type': 'application/x-www-form-urlencoded'
        }
   };

http request 使用axios,  content-type 改application/x-www-form-urlencoded

 

var params = new URLSearchParams();
params.append('keywords', this.keywords);

https://github.com/mzabriskie/axios/issues/362

但此法IE 不適用

最後送出

this.$http.post(url, params, config)
.then((response) => {
    // success callback
    console.log(response.data);
}, (response) => {
    // error callback
});

 

後記, 經現下的版本測試 只有chrome 認得URLSearchParams()  我總不能要求使用者使用特定browser 吧

只好默默改用application/json 傳值, server端再以object收值  或是parse json 的方式

 

END

你可能感興趣的文章

word題目轉google測驗 word題目轉google測驗

題庫批次匯入google表單 請先建一新試算表, 將題目轉成格式如下 並將網址列記下來, 後續的題目就是從此試算表讀出 題目 答案 選項一 選項二 選

vue.js modal 作兩個選項按鈕並導向不同頁面 vue.js modal 作兩個選項按鈕

axios vuejs application/x-www-form-urlencoded 送資料 VUE.JS 以 application/x-www-form-urlencoded 送資料

vue.js component 在parent與child 傳值 component 在parent與child 傳值

vue js 與teleport vue js 與 teleport 範例 <!DOCTYPE html> <html> <

隨機好文

java-身份証字號驗証 FormatCheck.java public class FormatCheck { private volatile

vue.js component 在parent與child 傳值 component 在parent與child 傳值

2018 hoc 掃地機器人 掃地機器人只能打掃沒有障礙物(桌椅、牆壁)的範圍,請寫程式控制機器人打掃餐廳的所有走道, 並在清掃完畢後回到充電器。

ArrayList 與 HashMap 範例 public static void main(String[] args) { String titleIds = &

Google sheet 建立成績單的總分及排名並提供名字下拉查詢 Google sheet, sum, rank, pull down list