vue面试题

 点击id为inner元素后,控制台打印是?

<template>
    <div>
      <div @click="clickMe">
        <div @click="clickMe" id="inner">点我</div>
      </div>
    </div>
</template>
<script>
    export default {
        name: "test",
      methods:{
          clickMe(){
            console.log('start')
            setTimeout(()=>{console.log('setTimeout1')},0)
            this.$nextTick(()=>{
              console.log('nextTick1')
              this.$nextTick(()=>{console.log('nextTick2')})
              setTimeout(()=>{console.log('setTimeout2')},0)
            })
            console.log('end')
          }
      }
    }
</script>
微任务、宏任务

start      end      nextTick      nextTick2
start      end      nextTick      nextTick2
setTimeout      setTimeout

上一篇:vue Promise异步操作


下一篇:nodejs中事件循环机制与面试题详解