1. 安装axios
npm install axios --save
  1. 声明axios变量
const axios = require('axios');
  1. 使用axios
axios({
        method: 'get',
        url: `http://localhost:8080/data/`,
        data: {
        	id: 1,
        	name: 'gugu'
		}
      }).then(res => {
        console.log(res);
      })

简单写法

axios.get('http://localhost:8080/data/', {
            data: {id: 1}
        }).then(res => {
            console.log(res);
        })
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐