beforeRouteEnter(to, from, next) { this.axios() }
对于这样的代码,会报错,因为此时组件实例不存在,没有this,就更没有挂载到上面的axios方法了。
next可以传入一个参数vm,这个参数表示组件实例,可以用vm代替this使用组件实例的方法了。
beforeRouteEnter(to, from, next) { next((vm) => { vm.axios() } }