<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 一、概述 使用 vue-router 實現路由導航功能,因此可以為路由配置一些守衛。 我們統一把導航守衛配置在 router/guards.js 文件中; ## 二、前置守衛 為每個前置導航守衛函數注入 to,from,next,options 四個參數: * `to: Route`: 即將要進入的目標[路由對象](https://router.vuejs.org/zh/api/#%E8%B7%AF%E7%94%B1%E5%AF%B9%E8%B1%A1) * `from: Route`: 當前導航正要離開的路由對象 * `next: Function`: 一定要調用該方法來 resolve 這個鉤子。執行效果依賴 next 方法的調用參數。詳情查看[Vue Router #導航守衛](https://router.vuejs.org/zh/guide/advanced/navigation-guards.html) * `options: Object`: 應用配置,包含: {router, i18n, store, message},可根據需要擴展。 ~~~ ## 如下,是登錄攔截導航守衛的定義 const loginGuard = (to, from, next, options) => { const {message} = options if (!loginIgnore.includes(to) && !checkAuthorization()) { message.warning('登錄已失效,請重新登錄') next({path: '/login'}) } else { next() } } ~~~ ## 三、后置守衛 你也可以定義后置導航守衛,為每個后置導航函數注入 to,from,options 三個參數: * `to: Route`: 即將要進入的目標[路由對象](https://router.vuejs.org/zh/api/#%E8%B7%AF%E7%94%B1%E5%AF%B9%E8%B1%A1) * `from: Route`: 當前導航正要離開的路由對象 * `options: Object`: 應用配置,包含: {router, i18n, store, message},可根據需要擴展。 ~~~ ## 如下,是一個后置導航守衛的定義 const afterGuard = (to, from, options) => { const {store, message} = options // 做些什么 message.info('do something') } ~~~ ## 四、應用 定義好導航守衛后,只需按照類別在 guard.js 中導出即可。分為兩類,`前置守衛`和`后置守衛`。如下: ~~~ export default { beforeEach: [loginGuard, authorityGuard], afterEach: [afterGuard] } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看