原因:axios 请求头中没有带 X-Requested-With 这个参数。
解决办法:
给请求头添加 X-Requested-With 这个参数,参数值为 XMLHttpRequest
// 以 axios 为例
this.$axios.get('http://yourdomain.com/api/getMenus',
{
headers: {'X-Requested-With': 'XMLHttpRequest'}
}).then((res)=>{
// console.log(res.data);
})