$nextTick : 获取更新后的dom(返回一个异步行为)
$nextTick( callback ){
return Promise.resolve().then(()=>{
callback();
})
}
<script>
class Vue{
constructor( options ){
options.created.bind(this)();
this.$el = document.querySelector(options.el);
}
$nextTick( callback ){
return Promise.resolve().then(()=>{
callback();
})
}
}
new Vue({
el:"#app",
created(){
this.$nextTick(()=>{
console.log( this.$el );
})
},
})
</script>