由于数据结构的原因,v-for 的是对象属性,每个属性又是一个对象,现在希望让列表按 order
这个属性进行排序,请问能做到吗?
const objects = {
prop1: { text: 'a', order: 3 },
prop2: { text: 'c', order: 1 },
prop3: { text: 'b', order: 2 },
}
<template v-for="(value, key) in objects">
<div>{{ value.text }}</div>
</template>
希望的 output
c
b
a