欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

vue路由如何實(shí)現(xiàn)網(wǎng)站導(dǎo)航功能-創(chuàng)新互聯(lián)

這篇文章給大家分享的是有關(guān)vue路由如何實(shí)現(xiàn)網(wǎng)站導(dǎo)航功能的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

創(chuàng)新互聯(lián)是專業(yè)的海城網(wǎng)站建設(shè)公司,海城接單;提供網(wǎng)站制作、成都網(wǎng)站建設(shè),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行海城網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

1、首先需要按照Vue router支持

npm install vue-router
然后需要在項(xiàng)目中引入:

import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

2、定義router的js文件

import Vue from 'vue'
import Router from 'vue-router'
import User from '../pages/user'
import Home from '../pages/public/home'
import Profile from '../pages/user/profile'
import Form from '../pages/form'
import Detail from '../pages/form/form'
import File from '../pages/form/file'
import Files from '../pages/file'

Vue.use(Router)

export default new Router({
 routes: [
  { path: '/', component:Home,
   children:[
    { path: '/user', component:Profile},
    { path: '/profile', component: User},
    { path: '/form', component: Form},
    { path: '/detail', component: Detail},
    { path: '/profiles', component: Files},
    { path: '/file', component: File}
   ]
  },

  { path: '/login', component:Login},
  { path: '/404', component:Error}
 ] 
})

3、在main.js中引入router

import router from './router'

new Vue({
 router,
 render: h => h(App),
}).$mount('#app')

4、入口頁面定義router-view

<div id="app">
 <router-view></router-view>
 </div>

5、在path指向?yàn)椤?”的頁面中,定義頁面的布局,例如:上(頭部)-中(左道航-右內(nèi)容)-下(底部)。

<HeaderSection></HeaderSection>
 <div>
  <NavList class="nav"></NavList>
  <router-view class="router"></router-view>
 </div>
<FooterSection></FooterSection>

6、左側(cè)導(dǎo)航,用elementUI實(shí)現(xiàn),有一個(gè)NavMenu導(dǎo)航菜單,做導(dǎo)航功能。

在這里提一下引入elementUI:

(1)安裝

npm i element-ui -S

(2)使用

在main.js中加入下面的代碼:

import ElementUI from 'element-ui';

  import 'element-ui/lib/theme-chalk/index.css';

  Vue.use(ElementUI);

導(dǎo)航欄的代碼如下:

<el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="collapse" background-color="#324157"
     text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened router>
 <template v-for="item in items">
  <template v-if="item.subs">
   <el-submenu :index="item.index" :key="item.index">
    <template slot="title">
    <i :class="item.icon"></i><span slot="title">{{ item.title }}</span>
    </template>
    <template v-for="subItem in item.subs">
    <el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
     <template slot="title">{{ subItem.title }}</template>
     <el-menu-item v-for="(threeItem,i) in subItem.subs" :key="i" :index="threeItem.index">
      {{ threeItem.title }}
     </el-menu-item>
    </el-submenu>
    <el-menu-item v-else :index="subItem.index" :key="subItem.index">
     {{ subItem.title }}
    </el-menu-item>
    </template>
   </el-submenu>
  </template>
  <template v-else>
   <el-menu-item :index="item.index" :key="item.index">
    <i :class="item.icon"></i><span slot="title">{{ item.title }}</span>
   </el-menu-item>
  </template>
 </template>
</el-menu>

定義左側(cè)導(dǎo)航的顯示和圖標(biāo)等內(nèi)容,index為唯一標(biāo)識(shí),打開的是path路徑,對(duì)應(yīng)router中的path,就可以打開寫好的相應(yīng)的頁面。

items: [
     {
      icon: 'el-icon-share',
      index: 'user',
      title: '系統(tǒng)首頁'
     },
     {
      icon: 'el-icon-time',
      index: 'profile',
      title: '基礎(chǔ)表格'
     },
     {
      icon: 'el-icon-bell',
      index: '3',
      title: '表單相關(guān)',
      subs: [
       {
        index: 'form',
        title: '基本表單'
       },
       {
        index: '3-2',
        title: '三級(jí)菜單',
        subs: [
         {
          index: 'detail',
          title: '富文本編輯器'
         },
         {
          index: 'file',
          title: 'markdown編輯器'
         },
        ]
       },
       {
        index: 'profiles',
        title: '文件上傳'
       }
      ]
     },
    ]

7、如果涉及到登錄頁面和不需要路由的頁面等,就需要在router的js文件中定義和“/”平級(jí)的其他path的頁面,再判斷進(jìn)入頁面是路由頁面還是登錄等頁面。

感謝各位的閱讀!關(guān)于“vue路由如何實(shí)現(xiàn)網(wǎng)站導(dǎo)航功能”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)站標(biāo)題:vue路由如何實(shí)現(xiàn)網(wǎng)站導(dǎo)航功能-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://chinadenli.net/article36/cdpjpg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、建站公司網(wǎng)站收錄、網(wǎng)頁設(shè)計(jì)公司網(wǎng)站維護(hù)、電子商務(wù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)