<script>
import axios from 'axios'
export default {
name: 'axios2-2',
created() {
let data = {
id: 12
}
// delete请求
axios.delete('/delete', {
params: { // 请求参数拼接在url上
id: 12
}
}).then(res => {
console.log(res)
})
axios.delete('/delete', {
data: { // 请求参数放在请求体
id: 12
}
}).then(res => {
console.log(res)
})
axios({
method: 'delete',
url: '/delete',
params: {}, // 请求参数拼接在url上
data: {} // 请求参数放在请求体
}).then(res => {
console.log(res)
})
},
}
</script>
请求参数拼接在url上用 params
let data = {
id: 12
}
// delete请求
axios.delete('/delete', {
params: { // 请求参数拼接在url上
id: 12
}
}).then(res => {
console.log(res)
})
请求参数放在请求体用 data
let data = {
id: 12
}
// delete请求
axios.delete('/delete', { // 请求参数放在请求体
data: {
id: 12
}
}).then(res => {
console.log(res)
})
转自Axios请求方法及别名(delete方法)_Argent_-CSDN博客_axios delete