我在 Vue.JS 上苦苦挣扎,该组件具有作为子项/插槽的一些带有画布数据的“复杂”组件(例如地图)。
我想避免当父组件重新渲染时,它们的内部插槽重新渲染。由于这些组件的工作方式(或任何其他场景),每次重新渲染时都需要执行所有“加载”步骤。即使保存他们的实时状态。
例如:
组件.vue
<template>
<div>
<span>{{value}}</span>
<slot></slot>
</div>
</template>
看法
<Component v-model="value">
<Map :latitude="0" :longitude="0"/>
</Component>
<script>
this.value = "Hello";
setTimeout(()=>{
this.value="Hello world!";
},1000);
</script>
有什么方法可以防止插槽在其父级重新渲染时重新渲染?
提前致谢。