import axios from 'axios' let data = {"code":"1234","name":"yyyy"}; axios.post(`${this.$url}/test/testRequest`,data) .then(res=>{ console.log('res=>',res); })
import axios from 'axios' let data = new FormData(); data.append('code','1234'); data.append('name','yyyy'); axios.post(`${this.$url}/test/testRequest`,data) .then(res=>{ console.log('res=>',res); })
import axios from 'axios' import qs from 'Qs' let data = {"code":"1234","name":"yyyy"}; axios.post(`${this.$url}/test/testRequest`,qs.stringify({ data })) .then(res=>{ console.log('res=>',res); })
總結:
一、從jquery轉到axios最難忘的就是要設置Content-Type,還好如今都搞懂了他們的原理
二、上面三種方式會對應後臺的請求方式,這個也要注意,好比java的@RequestBody,HttpSevletRequest等等java