vue導航欄跳轉路由

Element UI手冊:cloud.tencent.com/developer/d… 中文文檔:element-cn.eleme.io/#/zh-CN github地址:github.com/ElemeFE/ele…vue


1:components 新建頁面git

2:打開app.vue 寫代碼github

<template>
  <div>
   <el-col :span="2">   
    <el-menu
      :default-active="this.$route.path" 
      router mode="horizontal"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">
      <el-menu-item v-for="(item,i) in navList" :key="i" :index="item.name">
        <template slot="title">
          <i class="el-icon-s-platform"></i>
          <span> {{ item.navItem }}</span>
        </template>

      </el-menu-item>
       
        
    </el-menu>
  </el-col>
  
  <router-view     class="menu-right"/>

  </div>
</template>
<script>
  export default {
  	data() { 
  		return { 
  			navList:[ 
  			{name:'/components/ServiceHall',navItem:'服務大廳'}, 
  			{name:'/components/Management',navItem:'權限管理'},
  			{name:'/components/User',navItem:'用戶管理'}, 
  			{name:'/components/Personnel',navItem:'人員數據'}, 
  			{name:'/components/Alarm',navItem:'報警中心'}, 
  			] } 
  	},
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      }
    }
  }
</script>

<style>
	.menu-right{
		margin-left:200px;
	}
	
</style>
複製代碼

3:路由index.jsvue-router

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import ServiceHall from '@/components/ServiceHall'
import Management from '@/components/Management'
import User from '@/components/User'
import Personnel from '@/components/Personnel'
import Alarm from '@/components/Alarm'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
     {
      path: '/components/ServiceHall',
      name: 'ServiceHall',
      component: ServiceHall
    }, {
      path: '/components/Management',
      name: 'Management',
      component: Management
    },
     {
      path: '/components/User',
      name: 'User',
      component: User
    },{
      path: '/components/Personnel',
      name: 'Personnel',
      component: Personnel
    },{
      path: '/components/Alarm',
      name: 'Alarm',
      component: Alarm
    }
  ]
})


複製代碼

4:新頁面的內容,我寫的比較簡單,須要本身寫下功能需求所在的代碼bash

<template>	
	<div>
	我是權限管理頁面
	</div>	
</template>
<script>
</script>
<style>
</style>
複製代碼

5:效果就能夠看了 app


原文做者:祈澈姑娘ui

相關文章
相關標籤/搜索