axios

2018-10-08  本文已影响0人  xiezw96

axios跨域请求

第一步,安装依赖

cnpm install axios --save-dev

第二步,在main.js中加上

import axios from 'axios'
Vue.prototype.$http = axios

第三步,打开config下的index.js文件,在dev中的proxyTable加上

    proxyTable: {
      '/api': {
        target: 'http://localhost:8080/',
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    },

第四步

      this.$axios({
        method: 'get',
        url: 'hello'
      })
上一篇 下一篇

猜你喜欢

热点阅读