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

鍍金池/ 問答/HTML/ Vue單頁面應(yīng)用怎么加個別的頁面?

Vue單頁面應(yīng)用怎么加個別的頁面?

本來項目需求是單頁面,就做了公共的框架,包括側(cè)邊欄和頂部導(dǎo)航。
后來又說要把登錄注冊集成進去。
所以想問一下,怎么在同一個域名下加一個新頁面。

我現(xiàn)在的項目結(jié)構(gòu)是 側(cè)邊欄和頂部導(dǎo)航公共部分寫在app.vue里
然后在app.vue里用<router-view/> 配合vue-router的@click=router.push()
進行局部刷新的頁面切換。

現(xiàn)在需要把登錄注冊加進去,是單獨的頁面不需要公共部分。
不知道怎么做了。

登錄注冊可以是.html的也可以是.vue的,尋求一下幫助。

回答
編輯回答
枕頭人

使用嵌套路由

//router.js
  routes: [
    {
      path: '/index',
      name: 'index',
      component: Index,
      children:[
          {
              path:'page1'
              name: 'page1',
              component: Page1,
          },
          {
              path:'page2'
              name: 'page2',
              component: Page2,
          },
      ]
    },
    {
        path: '/login',
        name: 'login',
        component: Login,
    }
  ]
//app.vue
<template>
  <div id="app">
    <router-view />
  </div>
</template>
//index.vue
<template>
  <div id="index">
    <navigator />
    <sidebar />
    <router-view />
  </div>
</template>
2017年7月23日 19:39
編輯回答
笑忘初

單頁應(yīng)用(用 vue-router)的話,還是走路由配置,不要走 html 后綴,還是走 .vue 單文件組件

2017年4月26日 12:18
編輯回答
命于你

路由就能完美解決啊。
層級:
app.vue是程序的頂級出口(router-view):1.login 2.home(主頁面)
主頁面里面包含:2.1側(cè)邊欄 2.2頂部導(dǎo)航 2.3右側(cè)渲染區(qū)域出口(router-view)。
右側(cè)渲染區(qū)域出口:2.3.X 要展示的頁面
圖片描述

//基礎(chǔ)路由
import Home from '主頁面路徑'
import Login from '登錄頁面路徑'

//懶加載路由
const Welcome = resolve => require(['展示頁面路徑'], resolve)

routes:[

{
    path:'/login'
    name:'登錄頁面',
    component:Login,
},
{
    path:'/',
    name:'主頁',
    component:'Home',
    redirect: '/welcome',
    children: [
        { path: '/welcome', component: Welcome, name: '歡迎'}
    ]
}

]

2017年7月11日 10:45
編輯回答
久舊酒
<navigator v-if="$route.path!=='login'"/>
<sidebar v-if="$route.path!=='login'"/>

試試這樣

2017年5月3日 04:54