pixelqm
5 years ago
14 changed files with 236 additions and 49 deletions
-
5QMPlusVuePage/package-lock.json
-
87QMPlusVuePage/package.json
-
6QMPlusVuePage/src/App.vue
-
7QMPlusVuePage/src/main.js
-
26QMPlusVuePage/src/permission.js
-
47QMPlusVuePage/src/router/index.js
-
3QMPlusVuePage/src/utils/_import.js
-
9QMPlusVuePage/src/utils/asyncRouter.js
-
16QMPlusVuePage/src/view/dashbord/index.vue
-
16QMPlusVuePage/src/view/error/index.vue
-
16QMPlusVuePage/src/view/layout/index.vue
-
15QMPlusVuePage/src/view/login/login.vue
-
16QMPlusVuePage/src/view/login/regist.vue
-
16QMPlusVuePage/src/view/test/index.vue
@ -1,46 +1,47 @@ |
|||
{ |
|||
"name": "qm-plus-vue-page", |
|||
"version": "0.1.0", |
|||
"private": true, |
|||
"scripts": { |
|||
"serve": "vue-cli-service serve", |
|||
"build": "vue-cli-service build", |
|||
"lint": "vue-cli-service lint" |
|||
}, |
|||
"dependencies": { |
|||
"core-js": "^2.6.5", |
|||
"vue": "^2.6.10" |
|||
}, |
|||
"devDependencies": { |
|||
"@vue/cli-plugin-babel": "^3.11.0", |
|||
"@vue/cli-plugin-eslint": "^3.11.0", |
|||
"@vue/cli-service": "^3.11.0", |
|||
"babel-eslint": "^10.0.1", |
|||
"eslint": "^5.16.0", |
|||
"eslint-plugin-vue": "^5.0.0", |
|||
"vue-template-compiler": "^2.6.10" |
|||
}, |
|||
"eslintConfig": { |
|||
"root": true, |
|||
"env": { |
|||
"node": true |
|||
"name": "qm-plus-vue-page", |
|||
"version": "0.1.0", |
|||
"private": true, |
|||
"scripts": { |
|||
"serve": "vue-cli-service serve", |
|||
"build": "vue-cli-service build", |
|||
"lint": "vue-cli-service lint" |
|||
}, |
|||
"extends": [ |
|||
"plugin:vue/essential", |
|||
"eslint:recommended" |
|||
], |
|||
"rules": {}, |
|||
"parserOptions": { |
|||
"parser": "babel-eslint" |
|||
} |
|||
}, |
|||
"postcss": { |
|||
"plugins": { |
|||
"autoprefixer": {} |
|||
} |
|||
}, |
|||
"browserslist": [ |
|||
"> 1%", |
|||
"last 2 versions" |
|||
] |
|||
"dependencies": { |
|||
"core-js": "^2.6.5", |
|||
"vue": "^2.6.10", |
|||
"vue-router": "^3.1.3" |
|||
}, |
|||
"devDependencies": { |
|||
"@vue/cli-plugin-babel": "^3.11.0", |
|||
"@vue/cli-plugin-eslint": "^3.11.0", |
|||
"@vue/cli-service": "^3.11.0", |
|||
"babel-eslint": "^10.0.1", |
|||
"eslint": "^5.16.0", |
|||
"eslint-plugin-vue": "^5.0.0", |
|||
"vue-template-compiler": "^2.6.10" |
|||
}, |
|||
"eslintConfig": { |
|||
"root": true, |
|||
"env": { |
|||
"node": true |
|||
}, |
|||
"extends": [ |
|||
"plugin:vue/essential", |
|||
"eslint:recommended" |
|||
], |
|||
"rules": {}, |
|||
"parserOptions": { |
|||
"parser": "babel-eslint" |
|||
} |
|||
}, |
|||
"postcss": { |
|||
"plugins": { |
|||
"autoprefixer": {} |
|||
} |
|||
}, |
|||
"browserslist": [ |
|||
"> 1%", |
|||
"last 2 versions" |
|||
] |
|||
} |
@ -1,8 +1,11 @@ |
|||
import Vue from 'vue' |
|||
import App from './App.vue' |
|||
|
|||
import router from '@/router/index' |
|||
|
|||
Vue.config.productionTip = false |
|||
|
|||
new Vue({ |
|||
render: h => h(App), |
|||
}).$mount('#app') |
|||
render: h => h(App), |
|||
router |
|||
}).$mount('#app') |
@ -0,0 +1,26 @@ |
|||
import router from './router' |
|||
import { asyncRouterHandle } from '@/utils/asyncRouter'; |
|||
|
|||
router.beforeEach((to, from, next) => { |
|||
next() |
|||
// asyncRouterHandle(asyncRouter) // 等待动态使用 VUEX持久化 会将其放入 vuex并且动态生成左侧列表
|
|||
// router.addRoutes(asyncRouter)
|
|||
}) |
|||
|
|||
const asyncRouter = [{ |
|||
path: '/layout', |
|||
name: 'layout', |
|||
component: 'view/layout/index.vue', |
|||
meta: { |
|||
title: '首页', |
|||
}, |
|||
children: [{ |
|||
path: 'dashbord', |
|||
name: 'dashbord', |
|||
component: 'view/dashbord/index.vue' |
|||
}, { |
|||
path: "test", |
|||
name: "test", |
|||
component: "view/test/index.vue" |
|||
}] |
|||
}] |
@ -0,0 +1,47 @@ |
|||
import Vue from 'vue' |
|||
import Router from 'vue-router' |
|||
|
|||
Vue.use(Router) |
|||
|
|||
const baseRouters = [{ |
|||
path: '/', |
|||
redirect: '/login' |
|||
}, |
|||
{ |
|||
path: '/login', |
|||
name: 'login', |
|||
component: () => |
|||
import ('@/view/login/login.vue') |
|||
}, |
|||
{ |
|||
path: '/regist', |
|||
name: 'regist', |
|||
component: () => |
|||
import ('@/view/login/regist.vue') |
|||
}, |
|||
{ |
|||
path: "/error", |
|||
name: "error", |
|||
component: () => |
|||
import ('@/view/error/index.vue') |
|||
}, |
|||
{ |
|||
path: '*', |
|||
redirect: '/error' |
|||
|
|||
} |
|||
] |
|||
|
|||
// 需要通过后台数据来生成的组件
|
|||
|
|||
const createRouter = () => new Router({ |
|||
routes: baseRouters |
|||
}) |
|||
|
|||
const router = createRouter() |
|||
|
|||
export function resetRouter() { |
|||
const newRouter = createRouter() |
|||
router.matcher = newRouter.matcher |
|||
} |
|||
export default router |
@ -0,0 +1,3 @@ |
|||
module.exports = file => () => { |
|||
return import ('@/' + file) |
|||
} |
@ -0,0 +1,9 @@ |
|||
const _import = require('./_import') //获取组件的方法
|
|||
export const asyncRouterHandle = (asyncRouter) => { |
|||
asyncRouter.map(item => { |
|||
item.component = _import(item.component) |
|||
if (item.children) { |
|||
asyncRouterHandle(item.children) |
|||
} |
|||
}) |
|||
} |
@ -0,0 +1,16 @@ |
|||
<template> |
|||
<div> |
|||
Dashbord |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Dashbord" |
|||
|
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,16 @@ |
|||
<template> |
|||
<div> |
|||
404 |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Login" |
|||
|
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,16 @@ |
|||
<template> |
|||
<div> |
|||
模板框 |
|||
<router-view></router-view> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Layout" |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,15 @@ |
|||
<template> |
|||
<div> |
|||
登录 |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Login", |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,16 @@ |
|||
<template> |
|||
<div> |
|||
注册 |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Regist" |
|||
|
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,16 @@ |
|||
<template> |
|||
<div> |
|||
动态路由测试 |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Test" |
|||
|
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue