node简单服务器api
cors包
设置请求头方法
header("Access-Control-Allow-Origin: *"); // 允许任意域名发起的跨域请求
header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With');
Vue中psot请求后台node接收不到参数
let pars = new URLSearchParams();
pars.append("user","yhm");
this.$axios.post("/s",pars).then((res)=>{
console.log(res);
})
或者
import qs from 'qs';
Vue.prototype.$qs = qs;
this.$axios.post("/s", this.$qs.stringify({"user":"1213"})).then(res => {
console.log(res);
});