在函數(shù)外部用async包裹著內(nèi)容靴姿,然后用await在需要異步編譯的函數(shù)前面聲明沃但,就能夠達(dá)到異步編程的效果
mounted:async function(){
this.$store.commit('hiddentHead',{
hiddentHead:true
})
let res = await axios.get(api.detail+"?ids="+this.$route.query.id);
console.log(res)
// axios.get(api.detail+"?ids="+this.$route.query.id).then((res)=>{
// console.log(res)
// })
}
async和await必須要成雙,否則不起效