Skip to content

Latest commit

 

History

History
21 lines (18 loc) · 703 Bytes

dev.md

File metadata and controls

21 lines (18 loc) · 703 Bytes

vue2-sub-app

vue-router 源码中一段很精妙的代码:->

Vue.mixin({
  beforeCreate() {
    if (isDef(this.$options.router)) {
      this._routerRoot = this
      this._router = this.$options.router
      this._router.init(this)
      Vue.util.defineReactive(this, '_route', this._router.history.current)
    } else {
      this._routerRoot = (this.$parent && this.$parent._routerRoot) || this // <- this
    }
    registerInstance(this, this)
  },
})