Commit e0f10f60 authored by 何毅恒's avatar 何毅恒

后退不刷新优化

parent 7ebcda48
......@@ -21,7 +21,20 @@
</script>
<template>
<router-view></router-view>
<router-view v-slot="{ Component }">
<keep-alive>
<component
:is="Component"
:key="$route.name"
v-if="$route.meta.keepAlive"
/>
</keep-alive>
<component
:is="Component"
:key="$route.name"
v-if="!$route.meta.keepAlive"
/>
</router-view>
</template>
<style scoped lang="scss"></style>
......@@ -64,7 +64,7 @@ import {
} from "vue";
import { post } from "@/api/index";
import { useRouter } from "vue-router";
// import { wx } from "weixin-js-sdk";
onMounted(() => {
getInformationCategory();
......@@ -72,13 +72,14 @@ onMounted(() => {
script.type = "text/javascript";
script.src = "https://res.wx.qq.com/open/js/jweixin-1.3.2.js";
document.body.appendChild(script);
wx.miniProgram.postMessage({
data: {
url: "https://testhelp.gelifood.com/index.html",
title: "自定义帮助中心首页",
},
});
if (globalProperties.$wx.isWeixin()) {
wx.miniProgram.postMessage({
data: {
url: "https://testhelp.gelifood.com/index.html",
title: "格利帮助中心",
},
});
}
});
const ArticleItem = defineAsyncComponent(
() => import("@/components/ArticleItem.vue")
......
......@@ -7,22 +7,26 @@ const routes: Array<RouteRecordRaw> = [
name: "index",
component: () =>
import(/* webpackChunkName: "/" */ "@/pages/index.vue"),
meta:{keepAlive: false},
},
{
path: "/pc",
name: "pc",
component: () =>
import(/* webpackChunkName: "pcIndex" */ "@/pages/pc/index.vue"),
meta:{keepAlive: false},
children:[
{
path: '/pc/pcArticleList',
name: 'pcArticleList',
component: () => import(/* webpackChunkName: "pcArticleList" */'@/pages/pc/pcArticleList.vue'),
meta:{keepAlive: false},
},
{
path: '/pc/pcArticleDetail',
name: 'pcArticleDetail',
component: () => import(/* webpackChunkName: "pcArticleList" */'@/pages/pc/pcArticleDetail.vue'),
meta:{keepAlive: false},
},
]
},
......@@ -31,18 +35,21 @@ const routes: Array<RouteRecordRaw> = [
name: "mobile",
component: () =>
import(/* webpackChunkName: "About" */ "@/pages/mobile/index.vue"),
meta:{keepAlive: true},
},
{
path: "/articleDetails",
name: "articleDetails",
component: () =>
import(/* webpackChunkName: "About" */ "@/pages/mobile/articleDetails/index.vue"),
meta:{keepAlive: false},
},
{
path: "/search",
name: "search",
component: () =>
import(/* webpackChunkName: "About" */ "@/pages/mobile/search/index.vue"),
meta:{keepAlive: false},
},
];
const router = createRouter({
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment