valaxyjs / valaxy-theme-starter

🎨 Starter template for valaxy-theme.
https://starter.valaxy.site
MIT License
10 stars 2 forks source link

归档页点击排序按钮报错的问题 #12

Closed Sakurapole closed 6 months ago

Sakurapole commented 6 months ago

如下图: image image

原因: 代码中在进行数组逆序时,直接在原数组使用了reverse函数,导致原数组发生变化从而导致递归

修改: 在YunPostCollpase.vue这个文件中将

const sortedYears = computed(() => {
  const y = years.value
  const arr = y.sort((a, b) => b - a)
  return isDesc.value ? arr : arr.reverse()
})

修改为

const sortedYears = computed(() => {
  const y = years.value
  const arr = y.sort((a, b) => b - a)
  return isDesc.value ? arr : [...arr].reverse()
})
YunYouJun commented 6 months ago

感谢反馈,已修复。https://github.com/YunYouJun/valaxy/commit/7a4533e2211e0af5c8813ab4370a1d3fca2a4d1f