axios全局配置与创建实例
<script>
axios.defaults.baseURL='http://localhost:8080/student';//配置全局属性
axios.defaults.timeout=10000;//超时10s
axios.get('getAllstudent').then(res=>{//在全局配置基础上去网络请求
console.log(res);
})
</script>
创建axios的实例
const axiosInstance1 = axios.create({
baseURL: 'http://123.207.32.32:8000',
timeout: 5000
})
axiosInstance1({
url: '/home/data',
params: {
type:'pop',
page: 1
}
}).then(res => {
console.log(res.data)
})

浙公网安备 33010602011771号