刷新comp组件
美文网首页
2020-06-18

2020-06-18

作者: friendshi洛初Udo邭 | 来源:发表于2020-06-18 17:04 被阅读0次

<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>

相关文章

网友评论

      本文标题:2020-06-18

      本文链接:https://www.haomeiwen.com/subject/bzguxktx.html