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");