1.发送form-data形式
let formData = new FormData(); formData.append('username', data.username); // 添加键值对 formData.append('password', data.password); // 添加键值对 axios.post('http:/xxx/cms-admin/user/login', formData).then(response => { console.log("data:", response.data) if (response.data.status != 0) { ElMessage.error(response.data.errmsg) return } }).catch(error => { console.log("error:", error) })
2.发送json
post请求 [axios post的默认请求头是 application/json]
const data = reactive({ username: '', password: '', }) axios.post('http:/xxx/cms-admin/user/login', data).then(response => { console.log("data:", response.data) if (response.data.status != 0) { ElMessage.error(response.data.errmsg) return } }).catch(error => { console.log("error:", error) })
标签:axios,console,log,汇总,Vue,error,data,response From: https://www.cnblogs.com/zhaoyingjie/p/18331075