GET http://localhost:8080/fh/brand?address=&name=&pageNum=1&pageSize=5 404 (Not Found)

报错信息:
在这里插入图片描述
报错原因:这是vue配置跨域问题
原代码:

在这里插入图片描述
这个配置适合有自带config文件的,我的不带用不了

proxyTable: {
    
    
        '/fh': {
    
    
            target: 'http://localhost:8080/',//设置你调用的接口域名和端口号 别忘了加http
            changeOrigin: true,    //這裡true表示实现跨域
            pathRewrite: {
    
    
                '^/fh': '/'//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可
            }
        }
    }

我的没有config文件,可以有一下方式

在这里插入图片描述

  devServer: {
    
    
         proxy: {
    
    
             '/api':{
    
    
                target:'http://localhost:8080/',//设置你调用的接口域名和端口
                 changeOrigin:true,//這裡true表示实现跨域
                 pathRewrite:{
    
    
                   '/api':''
              }
             }
    }
}

发起请求:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/jq1223/article/details/114691715