Skip to content

Nested Router #1476

Closed
Closed
@znck

Description

@znck

What problem does this feature solve?

Create embedded app demo e.g.: https://reacttraining.com/react-router/web/example/basic

What does the proposed API look like?

  • Named export for history implementations (AbstractHistory mainly)
  • Don't use $router and $route reference on root vue instance
    // In install mixin
    beforeCreate: function beforeCreate () {
        if (isDef(this.$options.router)) {
          this._router = this.$options.router;
          this._router.init(this);
          Vue.util.defineReactive(this, '_route', this._router.history.current);
        } else {
          this._router = this.$parent.$router
          this._route = this.$parent.$route
        }
        registerInstance(this, this);
      }
     // Prototype getters
    Object.defineProperty(Vue.prototype, '$router', {
      get: function get () { return this._router || this.$root._router }
    });
    
    Object.defineProperty(Vue.prototype, '$route', {
      get: function get () { return this._route || this.$root._route }
    });
  • Modify matched route depth logic (stop at first ancestor with router) in <router-view>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions