text: import View from './components/view'
  import Link from './components/link'
  
  export let _Vue
  
  export function install (Vue) {
    if (install.installed && _Vue === Vue) return
    install.installed = true
  
    _Vue = Vue
  
    const isDef = v => v !== undefined
  
    const registerInstance = (vm, callVal) => {
      let i = vm.$options._parentVnode
      if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {
        i(vm, callVal)
      }
    }
  
    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
        }
        registerInstance(this, this)
      },
      destroyed () {
        registerInstance(this)
      }
    })
    // $router 就是传入 Vue的 router实例
    Object.defineProperty(Vue.prototype, '$router', {
      get () { return this._routerRoot._router }
    })
    // $route  就是 $router.history.current
    Object.defineProperty(Vue.prototype, '$route', {
      get () { return this._routerRoot._route }
    })
    // View，Link 组件注册
    Vue.component('RouterView', View)
    Vue.component('RouterLink', Link)
  
    const strats = Vue.config.optionMergeStrategies
    // use the same hook merging strategy for route hooks 对路由挂钩使用相同的挂钩合并策略
    strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created
  }
  