延遲和異步加載JS
defer
異步加載JS:sync

分配器、使用期,釋放期


js是單執行緒語言
首先執行主執行緒任務,再執行事件佇列



<script>
for (i = 0; i < 3; i++) {
setTimeout(() => {
console.log(i)
}, i * 1000);
}
</script>```
```javascript
axios({
url:'http://152.136.185.210:7878/api/m5/home/multidata',
method:'get'
}).then(res=>{
console.log(res);
})
axios({
url:'http://152.136.185.210:7878/api/m5/home/data',
params:{
type:'pop',
page:1
}}).then(
res => {
console.log(res);
})



axios.defaults.baseURL='http://152.136.185.210:7878/api/m5'
axios.defaults.timeout=5000
axios.all([axios({
// baseURL:'http://152.136.185.210:7878/api/m5',
url: '/home/multidata'
}),axios(
{
url:'/home/data',
params:{
type: 'sell',
page:5
}
}
)])
.then(axios.spread((res1,res2)=>{
console.log(res1);
console.log(res2);
}))


const instance = axios.create({
baseURL:'http://152.136.185.210:7878/api/m5/'
})
instance({
url:'/home/data',
params:{
type:'pop',
page:1
}
}).then(res => {
console.log(res);
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/287643.html
標籤:其他
