axios是一个http的请求库,与ajax类似
var url ="http://192.168.4.18:3000/search?keywords=你";axios.get("http://192.168.4.18:3000/search",{params:{keywords:"你"}//?后面的值可以放在params中}).then(res=>{console.log(res)})
baseURL
url = url + baseURL
<script>var url ="/search"axios({url,baseURL:"http://192.168.4.18:3000",method:"get",params:{keywords:"你"}}).then(res=>{console.log(res)})</script>
封装的axios
//jsvar baseURL ="http://192.168.4.18:3000/"function http({url,method="get",params={}}){return axios({url,baseURL,method,params})}//html<script>http({url:"/album?id=96964667"}).then(res=>{console.log(res)})http({url:"/album",params:{id:"96964667"}}).then(res=>{console.log(res)})</script>
