Vue源码解析
入门级
<body><div id="app"></div><script>class Vue {constructor(options) {// this=Vue 把options.created的this 指向Vue实例options.created.bind(this)();// this.$el 指向#appthis.$el = document.querySelector(options.el);// 把options.mounted的this 指向Vue实例options.mounted.bind(this)();}$nextTick(callback) {return Promise.resolve().then(callback);}}new Vue({el: "#app",created() {this.$nextTick(() => {console.log(this.$el);})},mounted() {console.log(this.$el);}})</script>
</body>