router c.js
const view = (name) => () => import('@/views/文件夹名/' + name)
export const c= [
{path: '/xxx',name: 'aaa',meta: {title: '哈哈哈',admin: true,keepAlive:true //加这个},component: view('xxx')
},
]
adminMain.vue
<keep-alive><router-view v-if="$route.meta.keepAlive" />
</keep-alive>
<router-view v-if="!$route.meta.keepAlive" />
.vue
// 需要刷新的时候 设置一个标记
sessionStorage.setItem('自定义字段名', 'submit') // submit随便是啥,有值能判断就行
beforeRouteEnter(to, from, next) {const mark = sessionStorage.getItem('自定义字段名')// 获取自定义字段// 从a页面回来并且没有标记,就不刷新,否则刷新if (from.name == 'a页面的name' && !mark) {next()} else {next((vm) => {if(from.name) {vm.刷新的函数()sessionStorage.removeItem('自定义字段名') //移除自定义字段}})}},
dialog遮罩层跳页未消失
<el-dialog title="标题"
:visible.sync="show"
:return-data="data"
:before-close="closeDialog"
:close-on-click-modal="false"
:modal-append-to-body='false' // 遮罩层只插入当前dialog的父元素,不在其他页显示
>
</el-dialog>
缓存后返回时表格格式窜行
activated() {this.$nextTick(() => {this.$refs.表格的ref.doLayout(); //解决表格错位});},