<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-witdth, initial-scale=1.0" /> <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <script src="/res/js/httpclt.js"></script> </head> <body> <div style="text-align: center" id="new-app"> <button onclick="getJSON();">Click</button> </div> </body> </html>
function getJSON(){ axios .get('/vue/package.json') .then(response => { const name = response.data.name console.log('get list', name) }) .catch(error => console.error(error)) }
https://juejin.cn/post/7218023140034084923
https://axios-http.com/docs/intro