[Vuejs]-Conditionally rendering the same component does not trigger mounted() hook

3👍

according to Linus Borg’s answer here, You should add a unique key attribute to both of them.

1👍

You can a achieve this by using key attribute
Specify different key for the 2 Map components.

<Map v-if="bool" mapSrc="src1.jpg" :idList="idList1" :data="dataVariable1" key="map1"></Map>
  <Map v-else mapSrc="src2.jpg" :idList="idList2" :data="dataVariable2" key="map2"></Map>
👤s4k1b

Leave a comment