码迷,mamicode.com
首页 > 其他好文 > 详细

异步async await 相关知识点总结以及代码练习

时间:2019-09-19 23:43:56      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:duration   ack   const   style   out   mys   export   timeout   wait   

<script>
const setTimeoutToPromise = duration => new Promise(resolve => {
    setTimeout(resolve, duration)
})
export default {
    data() {
        return {
            mysrc: true
        }
    },
    methods: {
        s1(a){
            console.log(a)
        },
        s2(a){
            console.log(a)
        },
        s3(a){
            console.log(a)
        },
        async s4(){
            this.s1(1)
            await setTimeoutToPromise(100).then(() => this.s2(2)).then()
            this.s3(3)
        }//输出顺序是132
    }
}
</script>

技术图片

 

 技术图片

 

 

技术图片

 

 

技术图片

 

 技术图片

 

 技术图片

 

技术图片

 

 

 技术图片

 

 

技术图片

 

 技术图片

 

 技术图片

 

 技术图片

 

 

 

技术图片

 

 

 

技术图片

 

 技术图片

 

 

 

技术图片

 

 

 

技术图片

 

 

技术图片

 

 技术图片

 

 

 

 

 

异步async await 相关知识点总结以及代码练习

标签:duration   ack   const   style   out   mys   export   timeout   wait   

原文地址:https://www.cnblogs.com/sugartang/p/11553076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!