I'm creating a basic table with a sorting feature:
<template>
<!-- more code -->
<tr v-for="item in sortBy(data.body, { name: 'name', order: 1 })">
<td v-for="field in item">{{ field }}</td>
</tr>
<!-- data.body => [{ name: Group 1 }, { name: Group2 }, // etc.] -->
</template>
props: {
data: {
type: Object,
default () {
return {}
}
}
},
methods: {
sortBy (data, params) {
// the warning disappears if I only leave "return data"
data.sort((a, b) => {
return a[params.name] - b[params.name] * params.order
})
return data
}
}
For some reason, I'm getting this warning:
[Vue warn]: You may have an infinite update loop in a component render function.
Why is this is and how to fix it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…