vue js 實(shí)例
<script type="text/javascript">
export default {
mounted:function(){
this.f1(this.f2);
this.f3();
},
methods:{
f1(callback){
console.log('f4')
setTimeout(function(){
console.log('f1')
callback();
},0)
},
f2(){
console.log('f2')
},
f3(){
console.log('f3')
},
},
}
</script>
結(jié)果 f4 f3 f1 f2
setTimeout 是異步的匹厘,time == 0 也一樣