国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

使用 Vue 類(lèi)別元件在 NuxtJs 專(zhuān)案中註冊(cè)附加掛鉤
P粉904450959
P粉904450959 2024-03-27 08:38:00
0
1
579

我正在建立我的第一個(gè) NuxtJs 項(xiàng)目,我還使用 Vue 類(lèi)別元件將我的元件編寫(xiě)為類(lèi)別。

應(yīng)用 Vue 類(lèi)別元件後,我在存取 beforeRouteEnter 元件掛鉤時(shí)遇到問(wèn)題(不再被呼叫)。因此,我找到了有關(guān)在使用此程式庫(kù)時(shí)註冊(cè)附加掛鉤的文檔,但我無(wú)法弄清楚將 import 語(yǔ)句放置在 NuxtJs 結(jié)構(gòu)中的位置。

我有這個(gè)文件(與文件相同):

// class-component-hooks.js
import Component from 'vue-class-component'

// Register the router hooks with their names
Component.registerHooks([
  'beforeRouteEnter',
  'beforeRouteLeave',
  'beforeRouteUpdate'
])

並且我希望獲得有關(guān)如何在我的 NuxtJs 專(zhuān)案中設(shè)定它的幫助:

// Where should I place this?
import './class-component-hooks'

P粉904450959
P粉904450959

全部回覆(1)
P粉879517403

結(jié)果非常簡(jiǎn)單:

我已將 .js 檔案放入 plugins 資料夾中:

// plugins/class-component-hooks.js
import Component from 'vue-class-component'

// Register the router hooks with their names
Component.registerHooks([
  'beforeRouteEnter',
  'beforeRouteLeave',
  'beforeRouteUpdate'
])

然後在我的 nuxt.config.js 檔案中,我放置了這一行:

...
  plugins: [
    { src: "~/plugins/class-component-hooks.js", mode: "client" },
  ],
...
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板