list 页面
beforeRouteEnter(to, from, next) {
if (from.name === ‘viewProduct’ || from.name === ‘viewProductDetail’) {
if (to.meta.isBack) {
to.meta.isBack = true
}
} else {
to.meta.isBack = false
}
next()
},
if (!this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …rs.page = this.store.getters.pages.page
this.filters.search = this.KaTeX parse error: Expected 'EOF', got '}' at position 32: …ges.search }̲ handleView…router.push({ name: ‘viewProductDetail’, query: { type: ‘view’ }})
this.KaTeX parse error: Expected 'EOF', got '}' at position 75: …res => {}) }̲, handleEdi…store.dispatch(‘searchCache/setfilter’, this.filters).then(res => {})
this.$router.push({ name: ‘viewProduct’, query: { type: ‘edit’ }})
},
编辑页面
beforeRouteLeave(to, from, next) {
if (to.name === ‘listProduct’) {
if (!this.submitLeave) {
to.meta.isBack = true
} else {
to.meta.isBack = false
}
}
next()
},
app.vue
<router-view v-if="!$route.meta.keepAlive"></router-view>
路由
/**
- 后台查询的菜单数据拼装成路由格式的数据
- @param routes
*/
export function generaMenu(routes, buttons, data) {
data.forEach(item => {
const menu = {
path: item.path,
component: item.component === ‘Layout’ ? Layout : DynamicRouterMap.dynamicRouterMap[item.component],
hidden: item.level === 1 ? !(!item.is_hidden && item.is_enabled) : !(!item.is_hidden && item.is_enabled),
children: [],
name: item.name,
meta: { keepAlive: true, isBack: false, title: item.title, icon: item.icon, show: !item.is_hidden && item.is_enabled
}
}
if (item.level !== 1) {
if (item.is_enabled) {
var str = (item.name)
buttons.push(str)
}
}
if (item.sys_permission_sheets) {
generaMenu(menu.children, buttons, item.sys_permission_sheets)
}
if (item.level !== 3) {
if (item.type !== 1) {
routes.push(menu)
}
}
})
var dynamicMes = { routesBean: routes, buttonBean: buttons }
return dynamicMes
}