html
代码语言:javascript复制<div v-for="(layer, index) in layerList" :key="layer.id" class="layer-item">
<div>{{ layer.name }}</div>
</div>
JavaScript
解决方案 1 :
给 state 增加 computed
代码语言:javascript复制<script setup>
import { useLayerStore } from "@/stores/";
解决方案 2:
给 useStore 使用 storeToRefs
代码语言:javascript复制<script setup>
import { useLayerStore } from "@/stores/";
import { storeToRefs } from "pinia";
const layer = useLayerStore();
const { layerList } = storeToRefs(layer);
</script>
参考文档