Blogger Information
Blog 28
fans 0
comment 0
visits 65158
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404
蒸蒸
Original
5607 people have browsed it

以下代码在运行时报错:

  1. axios.get('index.php/six_products/tools/showport').then(res => {
  2. const data = res.data
  3. console.log(data);
  4. })

报错内容:加载资源失败

报错原因:
定义了路由,还在使用原来的路径进行访问

  1. //定义路由,允许跨域访问
  2. Route::rule('api/showport','six_products/tools/showport')->allowCrossDomain();

正确的访问方式:按照路由定义的地址访问

  1. axios.get('index.php/api/showport').then(res => {
  2. const data = res.data
  3. console.log(data);
  4. })
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post