axios的CDN引入链接
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
axios的GET请求
const btns = document.querySelectorAll('button'); // 配置baseURL axios.defaults.baseURL = 'http://localhost:8000'; btns[0].onclick = function() { axios.get('/axios-server',{ // url参数 params: { id: 666666, name: 'justin' }, // 请求头信息 headers: { color: "red" } }).then(value => {console.log(value);}) }