1. 在App.vue 文件里写入provide 方法
<script setup></script><template><a-config-provider :locale="localezhCN" :autoInsertSpaceInButton="false"><el-config-provider :locale="locale"><router-view v-wechat-title="$route.meta.title" v-if="isRouterAlive" /></el-config-provider></a-config-provider>
</template><script>
import zhCn from "element-plus/es/locale/lang/zh-cn";
import zhCN from "ant-design-vue/es/locale/zh_CN";
export default {//局部组件components: {},//ludata() {return {isRouterAlive: true,};},setup() {//设置中文return {locale: zhCn,localezhCN: zhCN,};},//luprovide() {return {reload: this.reload,};},//lumethods: {async reload() {this.isRouterAlive = false;await this.$nextTick();this.isRouterAlive = true;},},
};
</script>
<style>
@import url("./assets/css/base.css");
</style>
2. 在需要刷新的页码使用inject引入
<script>export default {inject:['reload'], //注入依赖mounted() {if (location.href.indexOf("#Case") == -1) {location.href = location.href + "#Case";this.reload();}}
}
</script>