簡體   English   中英

在 vue-router 路由中使用絕對路徑

[英]Using an absolute path in a vue-router route

在我的 Vue 應用程序中,我有以下路線(以及其他路線)

  {
    path: '/event/:eventId?',
    name: 'event',
    component: EventTask
  },
  {
    path: '/terms-and-conditions',
    name: 'terms-and-conditions',
    component: TermsAndConditions
  }

條款和條件的鏈接顯示在頁腳中,因此可以從任何頁面訪問。 如果我在活動路線上,我點擊了條款和條件的鏈接

<router-link to="terms-and-conditions">
  <v-btn text>Terms of Use</v-btn>
</router-link>

瀏覽器導航到路徑/event/terms-and-conditions而不是/terms-and-conditions 我怎樣才能使它成為一個絕對的路線,所以它總是導航到/terms-and-conditions

您可以指定路線的名稱

<router-link :to="{ name: 'terms-and-condition' }">
   <v-btn text>Terms of Use</v-btn>
<router-link>

https://router.vuejs.org/api/#to

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM