我的猜测是,当您定义歌曲计算的属性时,它与V-For循环中的歌曲变量发生冲突。但这是迄今为止我可以猜到的,除非您提供更多信息。
<script lang="ts" setup>
const songStore = useSongStore();
const songList = computed(() => songStore.songList.value);
const currentSong = computed(() => songStore.getCurrentSong.value);
</script>
<template>
<ul>
<li
v-for="(song, $song_index) in songList"
:key="song.id"
:class="{'current-play' : song.id === currentSong.id}"
>
{{ $song_index + 1 }} - {{ song?.name }}
</li>
</ul>
</template>