【无标题】

导航左-菜单 交互后台

LeftNav.vue:



通过动态路由跳转为当前项内容

router :default-active="$route.path"

定义组件的和路由的关系

index.js

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import AppMain from '@/components/AppMain'
import LeftNav from '@/components/LeftNav'
import TopNav from '@/components/TopNav'
import Login from '@/views/Login'
import Register from '@/views/Register'
 
import AddBook from '@/views/book/AddBook'
import BookList from '@/views/book/BookList'
 
 
Vue.use(Router)
 
export default new Router({
	routes: [{
			path: '/',
			name: 'Login',
			component: Login
		},
		{
			path: '/Register',
			name: 'Register',
			component: Register
		},
		{
			path: '/HelloWorld',
			name: 'HelloWorld',
			component: HelloWorld
		},
		{
			path: '/AppMain',
			name: 'AppMain',
			component: AppMain,
			children:[{
				path: '/TopNav',
				name: 'TopNav',
				component: TopNav
			}, {
				path: '/LeftNav',
				name: 'LeftNav',
				component: LeftNav
			},
			{
				path: '/book/AddBook',
				name: 'AddBook',
				component: AddBook
			}, {
				path: '/book/BookList',
				name: 'BookList',
				component: BookList
			}]
		}
 
	]
})

action.js

/**
 * 对后台请求的地址的封装,URL格式如下:
 * 模块名_实体名_操作
 */
export default {
	'SERVER': 'http://localhost:8080', //服务器
	'SYSTEM_USER_DOLOGIN': '/user/userLogin', //登陆
	'SYSTEM_USER_DOREG': '/user/Register', //注册
	'SYSTEM_MENUS': '/module/queryRootNode', //左侧菜单树
	'BOOK_LIST': '/book/queryBookPager', //书籍列表
	'getFullPath': k => { //获得请求的完整地址,用于mockjs测试时使用
		return this.SERVER + this[k];
	}
}

数据表格

BookList.vue


 

 

 效果图:

【无标题】_第1张图片

你可能感兴趣的:(vue.js,javascript,elementui)