欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 锐评 > vue 当前页面刷新 provide + inject

vue 当前页面刷新 provide + inject

2024/10/24 20:23:18 来源:https://blog.csdn.net/CMDN123456/article/details/140669210  浏览:    关键词:vue 当前页面刷新 provide + inject

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>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com