vue3 中 pinia 的 state 修改模版绑定的 state 数据没更新?

发布时间 2023-03-28 12:56:47作者: 蓓蕾心晴

解决方案:

给 state 增加 computed

import { useLayerStore } from "@/stores/";

const layer = useLayerStore();
const layerList = computed(() => layer.layerList);
<div v-for="(layer, index) in layerList" :key="layer.id" class="layer-item">
    <div>{{ layer.name }}</div>
</div>