通過多次查詢並嘗試,找到了兩種結局辦法
方法一:使用qs解決
npm install qs --save-dev
在main.js中引入qs
import qs from 'qs'
Vue.prototype.$qs = qs
在.vue文件中使用
let params = {
mobile: that.mobile,
code: that.code
}
that.$ajax.post(that.GLOBAL.url + 'c=members&a=codeLogin', that.$qs.stringify(params))
.then(function (response) {
console.log(response)
})
.catch(function (error) {
console.log(error)
})
方法二:使用URLSearchParams傳遞參數,網上大多數都是這樣的方法
let param = new URLSearchParams()
param.append('mobile', that.mobile)
param.append('code', that.code)
that.$ajax.post(url, param)
.then(function (response) {
that.$emit('hidden')
console.log(response)
})
.catch(function (error) {
console.log(error)
})