vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404
程序员文章站
2022-03-03 22:05:19
...
以下代码在运行时报错:
axios.get('index.php/six_products/tools/showport').then(res => {
const data = res.data
console.log(data);
})
报错内容:加载资源失败
报错原因:
定义了路由,还在使用原来的路径进行访问
//定义路由,允许跨域访问
Route::rule('api/showport','six_products/tools/showport')->allowCrossDomain();
正确的访问方式:按照路由定义的地址访问
axios.get('index.php/api/showport').then(res => {
const data = res.data
console.log(data);
})
推荐阅读
-
VUE 登录不上,F12报错Uncaught (in promise) Error: Request failed with status code 404
-
Uncaught (in promise) Error: Request failed with status code 404
-
axios请求报Uncaught (in promise) Error: Request failed with status code 404
-
axios请求报Uncaught (in promise) Error: Request failed with status code 404
-
vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404
-
vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404