本文共 1170 字,大约阅读时间需要 3 分钟。
npm install axios
import axios from 'axios' //可以直接在index.html页面引入,不过最好在component的js里引入
主目录\config\index.js文件在module.exports.proxyTable中进行配置
proxyTable: {           '/api': {     	/     '/api'代表的是你取得名字        target: 'http://localhost:8088',  	//这一段代表的是’api'所代表的地址        changeOrigin: true,          pathRewrite: {               '^/api': ''          }        }      },   其他语法自行查询
methods: {      getUsers() {        axios        //		‘/api'代表的是  'http://localhost:8088'        //		所以'/api/vue/getAllUsers'就是        // 		'http://localhost:8088/vue/getAllUsers'          .get('/api/vue/getAllUsers').then((response) => {          this.users = response.data;        })      }    }   转载地址:http://ghesz.baihongyu.com/