• 周四. 4月 25th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

v-if 组件未销毁

admin

11月 28, 2021

今天开发遇到一个问题,我复用了两个高度相似的组件,在用 v-if 配合开关进行展示的时候,发现组件并未被成功销毁:

解决方法:给两个组件添加不同的  :key=”” 

出现问题的代码:

<!-- List2 -->
<List v-if="whichList===2" :whichList="2"></List>

<!-- List1 -->
<List v-if="whichList===1" :whichList="1"></List>

解决后:

<!-- List2 -->
<List v-if="whichList===2" :whichList="2" :key="2"></List>

<!-- List1 -->
<List v-if="whichList===1" :whichList="1" :key="1"></List>

《v-if 组件未销毁》有一个想法
  1. EndoPump is a dietary supplement for men’s health. This supplement is said to improve the strength and stamina required by your body to perform various physical tasks. Because the supplement addresses issues associated with aging, it also provides support for a variety of other age-related issues that may affect the body. https://endopumpbuynow.us/

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注