鍍金池/ 問答/Linux  HTML/ vue,按鈕是v-for遍歷出來的,點擊每一個按鈕進入到指定的頁面,路由配置這一

vue,按鈕是v-for遍歷出來的,點擊每一個按鈕進入到指定的頁面,路由配置這一塊不會寫

圖片描述

<section>

<div class="nav">
    <div class="nav_con">
        <router-link :to="{path:item.link,query:{title:item.title,category_id:item.id}}" class="nav_item" v-for="item in Nav" :key="item.id">
            <span class="nav_img"><img :src="item.icon"></span>
            <i class="nav_text">{{item.title}}</i>
        </router-link>
    </div>
</div>

</section>

我在本地json中定義了link,但是實際后臺數(shù)據(jù)中沒有,需要自己配置路由,知道是用變量,但就是不會寫。

回答
編輯回答
遺莣

path路徑對應(yīng)的值就是你要跳轉(zhuǎn)的頁面對應(yīng)的路徑

2017年6月15日 13:17
編輯回答
笨尐豬

哪部分代碼不會寫

2017年5月27日 07:37
編輯回答
絯孑氣

多翻翻官方文檔應(yīng)該就可以解決吧,組件里放一個<router-view>

路由配置如下:

const router = new VueRouter({
  routes: [
    {
      path: '/user/:id', component: User,
      children: [
        // 當(dāng) /user/:id 匹配成功,
        // UserHome 會被渲染在 User 的 <router-view> 中
        { path: '', component: UserHome },

        // ...其他子路由
      ]
    }
  ]
})
2017年2月2日 00:04
編輯回答
瘋子范

把json數(shù)據(jù)序列化到nav不就行了?

2017年5月4日 11:00
編輯回答
影魅

有個比較野蠻的辦法,就是告訴你的后臺 ,你頁面的路由名稱(在跳轉(zhuǎn)頁面是固定的情況下)

2017年10月26日 02:56