用axios提交文件显示404 cannot post?

依依雨柔
  • 233

clipboard.png

clipboard.png
Request URL: http://localhost:8081/api/tableData.json
Request Method: POST
Status Code: 404 Not Found
Remote Address: 127.0.0.1:8081
Referrer Policy: no-referrer-when-downgrade
connection: close
content-length: 166
content-security-policy: default-src 'self'
content-type: text/html; charset=utf-8
date: Thu, 27 Sep 2018 06:43:10 GMT
Vary: Accept-Encoding
x-content-type-options: nosniff
x-powered-by: Express
Accept: application/json, text/plain, /
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Content-Length: 0
Host: localhost:8081
Origin: http://localhost:8081
Referer: http://localhost:8081/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36

init () {
      axios.post('/api/tableData.json')
        .then(this.handleGetDataSucc)
    },
    handleGetDataSucc(res){
      res=res.data
      if(res.ret && res.data) {
        const data = res.data
        this.pageData = data.pageData
      }
      为什么设置代理后访问不到数据?
回复
阅读 3.1k
2 个回答
✓ 已被采纳

cannot post
为什么不用get?

yeungx
  • 876

clipboard.png

留意下 port 是你本地运行的vue 程序端口。proxyTable 中的 target 应该是后端接口的端口。
这样用不觉得冲突么。
运行路径 都是 localhost:8081 .

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏