zoukankan      html  css  js  c++  java
  • vue-router的钩子

    vue-router的钩子分为三类:

    1. 全局钩子
    2. 路由独享钩子
    3. 组件内钩子

    1. 全局钩子

    beforeEach(to,from,next)

    afterEach(route)

    2. 路由独享钩子

    beforeEnter(to,form,next)

    beforeLeave(to,from,next)

    3. 组件内钩子

    beforeRouteEnter(to,from,next) 不能获取组件实例this,此时组件实例还没被创建

    beforeRouteLeave(to,from,next)

    beforeRouteUpdate(to,from,next)

    4. 钩子的参数说明

    form:当前导航要离开的路由
    to: 即将要进入的目标
    next: 用next方法resolve钩子

    next(): 进行管道中的下一个钩子
    next(false): 中断当前导航
    next('/')或next({path:'/'}):跳转到一个不同的地址。当前导航呗中断,进行一个新的导航

  • 相关阅读:
    1月19日
    1月18日
    1月17日
    读后感(1)
    UIAlertView
    plist
    jQuery validation
    HTML <a href >标签的target属性
    HTML DOM
    .与..的区别
  • 原文地址:https://www.cnblogs.com/mengff/p/9522824.html
Copyright © 2011-2022 走看看