日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 Vue 正文

vue3實現頁面刷新

作者:鳴拙 更新時間: 2022-04-05 Vue

vue3實現頁面刷新

在muuri的復雜實現中,拖動元素后,只能刷新頁面才能重置回初始狀態

在組件中實現頁面的刷新功能

//App.vue頁面
//html:
<template>
  <HelloWorld v-if="isRouterAlive"></HelloWorld>
</template>

<script>
import { provide, ref, nextTick } from "vue";
import HelloWorld from "./components/vue3/index.vue";

export default {
  name: "App",
  components: {
    HelloWorld,
  },
  setup() {
    const isRouterAlive  = ref(true);
    const reload = () => {
      isRouterAlive.value = false;
      nextTick(() => {
        isRouterAlive.value = true
      })
    }
    provide("reload", reload);
    return { isRouterAlive }
  },
};
</script>
//在需要使用的頁面引用即可
const myFn = inject<any>("reload");

原文鏈接:https://blog.csdn.net/weixin_45939191/article/details/121556188

欄目分類
最近更新