bug fix: 修复切换动态路由的时候的报错

This commit is contained in:
huzhushan 2021-04-28 17:48:59 +08:00
parent ea15067070
commit 6a5a426057
4 changed files with 63 additions and 7 deletions

View File

@ -3,7 +3,7 @@
* @version:
* @Date: 2021-04-21 09:18:32
* @LastEditors: huzhushan@126.com
* @LastEditTime: 2021-04-23 10:49:35
* @LastEditTime: 2021-04-28 16:49:53
* @Author: huzhushan@126.com
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
* @Github: https://github.com/huzhushan/vue3-element-admin
@ -12,6 +12,7 @@
const Layout = () => import('@/layout/index.vue')
const List = () => import('@/views/test/index.vue')
const Add = () => import('@/views/test/Add.vue')
const Edit = () => import('@/views/test/Edit.vue')
const Auth = () => import('@/views/test/Auth.vue')
const NoAuth = () => import('@/views/test/NoAuth.vue')
const Nest = () => import('@/views/test/Nest.vue')
@ -51,6 +52,16 @@ export default [
},
hidden: true, // 不在菜单中显示
},
{
path: 'edit/:id',
name: 'testEdit',
component: Edit,
meta: {
title: '编辑',
roles: ['admin', 'visitor'],
},
hidden: true, // 不在菜单中显示
},
{
path: 'auth',
name: 'testAuth',

View File

@ -3,7 +3,7 @@
* @version:
* @Date: 2021-04-20 11:06:21
* @LastEditors: huzhushan@126.com
* @LastEditTime: 2021-04-21 09:34:20
* @LastEditTime: 2021-04-28 17:40:11
* @Author: huzhushan@126.com
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
* @Github: https://github.com/huzhushan/vue3-element-admin
@ -20,7 +20,7 @@ const state = {
}
const mutations = {
ADD_TAG_LIST: (state, { path, fullPath, name, meta }) => {
ADD_TAG_LIST: (state, { path, fullPath, name, meta, params, query }) => {
if (state.tagList.some(v => v.path === path)) return false
state.tagList.splice(
@ -28,7 +28,7 @@ const mutations = {
0,
Object.assign(
{},
{ path, fullPath, name, meta },
{ path, fullPath, name, meta, params, query },
{
title: meta.title || '未命名',
fullPath: fullPath || path,
@ -156,8 +156,8 @@ const actions = {
commit('DEL_ALL_CACHE_LIST')
},
updateTagList({ commit }, tag) {
commit('UPDATE_TAG_LIST', tag)
updateTagList({ commit }, { path, fullPath, name, meta, params, query }) {
commit('UPDATE_TAG_LIST', { path, fullPath, name, meta, params, query })
},
}

39
src/views/test/Edit.vue Normal file
View File

@ -0,0 +1,39 @@
<!--
* _oo0oo_
* o8888888o
* 88" . "88
* (| -_- |)
* 0\ = /0
* ___/`---'\___
* .' \\| |// '.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\---/'' |_/ |
* \ .-\__ '-' ___/-. /
* ___'. .' /--.--\ `. .'___
* ."" '< `.___\_<|>_/___.' >' "".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `_. \_ __\ /__ _/ .-` / /
* =====`-.____`.___ \_____/___.-`___.-'=====
* `=---='
*
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 佛祖保佑 永不宕机 永无BUG
*
* @Descripttion:
* @version:
* @Date: 2021-04-28 16:50:05
* @LastEditors: huzhushan@126.com
* @LastEditTime: 2021-04-28 16:50:41
* @Author: huzhushan@126.com
* @HomePage: https://huzhushan.gitee.io/vue3-element-admin
* @Github: https://github.com/huzhushan/vue3-element-admin
* @Donate: https://huzhushan.gitee.io/vue3-element-admin/donate/
-->
<template>
<h2>编辑页面 id:{{ $route.params.id }}</h2>
</template>

View File

@ -25,7 +25,13 @@
</el-button>
</template>
<template #operate="scope">
<el-button size="mini" type="primary">编辑</el-button>
<el-button
size="mini"
type="primary"
@click="$router.push(`/test/edit/${scope.row.id}`)"
>
编辑
</el-button>
<el-button size="mini" type="danger">删除</el-button>
</template>
</pro-table>