vue3.0 nextTick()刷新组件

// App.vue

<router-view v-if="refpage"></router-view> import { provide, ref, nextTick } from "vue";    export default {   setup() {     const refpage = ref(true);     const reaload = () => {       refpage.value = false;       nextTick(() => {         refpage.value = true;       });     };     provide("reaload", reaload);     return {       refpage     };   } };   // xxx.vue <div @click="clickdata">重载组件</div> import { inject } from "vue"; setup(){     const realoads = inject("reaload");   console.log(realoads, "测试");   const clickdata = ()=> {       realoads() }   return{     clickdata // 绑定到元素上   } } https://vue3js.cn/docs/zh/guide/composition-api-provide-inject.html#%E4%BF%AE%E6%94%B9%E5%93%8D%E5%BA%94%E5%BC%8F-property // 官网 https://blog.csdn.net/qq_41619796/article/details/114533877     //参考这个老哥写的
上一篇:js执行机制


下一篇:VUE实现消息更新自动滚动到页面最底部