在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 如何解決vue-router的子頁面不渲染?

如何解決vue-router的子頁面不渲染?

其實就是想實現(xiàn)一個最簡單的vue路由的功能,用的是vue-router2.0.0,我的代碼是這樣的:

視圖層:

<div id="box">
    <div>
        <router-link to="/index">首頁</router-link>
        <router-link to="/news">新聞</router-link>
    </div>

    <router-view></router-view>
</div>

js:

const index={template:"<h3>我是主頁</h3>"};
    const news={template:'<h3>我是新聞頁</h3>'};
    const routers=[
        {path:'/', redirect:'/index'},
        {path:'/index', component:index},
        {path:'/news', component:news}
    ]
    const newRouter=new VueRouter({
        routers:routers
    })

    const app=new Vue({
        el:'#box',
        router:newRouter
    })

最后的效果:
圖片描述

回答
編輯回答
網(wǎng)妓

new VueRouter里面
routers:routers 改為 routes: routers

2017年5月23日 01:26