1.dataType,是后台接口返回的數據格式,eg:dataType:json
2.contentType,是前台傳給后台的數據格式(后台response,返回時,也有數據格式,一般不用管,但當導出文件等時,后台就需要設置對應的contentType數據格式),eg:content-type :application/json,后台用@RequestBody標注model或map,來接收參數。前台需要使用JSON.stringify()【axios貌似不需要JSON.stringify處理,加上也沒錯】
JSON.stringify(params),將前台參數,轉為json字符串,傳給后台。
JSON.parse(),將json字符串,轉為json對象。
contenType,還有文件,表單,等等對應請求類型的數據格式。
3.axios,contentType默認是application/json
傳formData時,要指明contentType為表單的,並且數據需要Qs.stringify處理