什么时候使用router或storeinnewVue()?constapp=newVue({router,store}).$mount('#app')上例讲vue对象时为什么可以传入router和store对象?,什么时候用?保存的位置newvue实际上调用了源码中的如下方法应该用`new`关键字调用')}this._init(options)}也就是说,router、store等参数都保存在options参数中。vue-router源码的install方法中使用了如下代码options.routerthis._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)}})在VUE根组件中,newvue传入的options对象可以通过this.$options.router获取这里是还有一个技巧是如何让所有的子组件都得到vue和组件初始化的对象,比如这里的this._routerRoot。关键是this.$parent
