开题
这篇文章大概总结了Vue 中 axios 的传输数据问题,算是给自己一个记录!
Vue axios get方式
axios.get('/JiaKitchen/User/login', {
params: {
uname: this.form.username,
upassword: this.form.password
}
}).then(res => {
if (res.data.flag) {
this.$router.push('/main')
} else {
this.dialogVisible = true
return false
}
})
Vue axios post
要引入qs组件
const postData = this.$qs.stringify({
uname: this.form.username,
upassword: this.form.password
})
axios.post('/JiaKitchen/User/login', postData).then(res => {
console.log(res.data)
if (res.data.flag) {
this.$router.push('/main')
} else {
this.dialogVisible = true
return false
}
})