方法一:使用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) })