<template><compv-if="updates"></comp><button@click="reload()">刷新comp组件</button></template><script>import comp from '@/views/comp.vue'export default { name: 'parentComp', data() { return { updates: true } }, methods: { reload() { // 移除组件 this.updates= false // 在组件移除后,重新渲染组件 // this.$nextTick可实现在DOM 状态更新后,执行传入的方法。 this.$nextTick(() => { this.updates = true }) } }}</script>
网友评论