原因: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);
})