码迷,mamicode.com
首页 > Web开发 > 详细

插件http-proxy-middleware在vue-cli中的使用

时间:2017-11-12 19:23:56      阅读:598      评论:0      收藏:0      [点我收藏+]

标签:config文件   分享   sea   conf   创建   config   webpack   调用   学习资料   

作用:把后端的API(远程的API) 请求代理到本地服务器上,方便与后台数据调试,前后端分离

server.js 模拟远程API :localhost:8060/api/search  (测试前运行 node server.js)

  技术分享

在vue-cli中的使用:运行localhost: 8080

    1.在config文件夹下创建proxyConfig.js如下

        技术分享

    2. 在/config/index.js中 引入,并配置

      const  proxyConfig = require(‘./proxyConfig‘)

          技术分享

          

 

前端http请求远程API:在create钩子时调用 this.test() 请求到API结果:我是远程的数据源

      技术分享

 学习资料详细:

      1.https://github.com/chimurai/http-proxy-middleware

      2.https://vuejs-templates.github.io/webpack/proxy.htm

  

插件http-proxy-middleware在vue-cli中的使用

标签:config文件   分享   sea   conf   创建   config   webpack   调用   学习资料   

原文地址:http://www.cnblogs.com/xshaohua-com/p/7822399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!