axios发送异步 PHP接收不到解决方案
发送异步数据格式不是Form Data
Content-Type: application/x-www-form-urlencoded
解决办法:
引入qs库 https://github.com/ljharb/qs
const qs = require('qs');
axios.post('/foo', qs.stringify({ 'bar': 123 }));
eg:
require(['node_modules/axios/dist/axios','node_modules/vue/dist/vue','node_modules/qs/dist/qs'],function(axios,Vue,qs){
var app = new Vue({
el:'#app',
data:{
},
methods:{
result(){
axios.post('1.php', qs.stringify(this.article))
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
}
}
})
});