解决axios post 提交x-www-form-urlencoded格式错乱:
代码语言:javascript复制<script>
import axios from 'axios'
import qs from 'qs';
export default {
name: 'Action',
data() {
return {
phone_wid: "",
openid: ""
}
},
methods: {
onSubmit() {
this.openid = ""
const url = "/go_action"
let param = {
'serviceName': '***',
'methodName': '**',
'paramterInput': `{"appid":'****',"is_needTag":false,"pid":**,"source":1,"wid":${this.phone_wid}}`
}
let data = qs.stringify(param)
console.log(data)
axios.post(url, data,
{
headers: {
'apiclient-auth': '******',
'Content-Type': 'application/x-www-form-urlencoded'
}
}
).then((res) => {
console.log(res.data.responseVo.infos[0].openid)
this.openid = res.data.responseVo.infos[0].openid
})
}
}
}
</script>