You get an error because you create an infinite loop when called fruit.sort()in an instruction v-for.
fruit.sort() (), Vue , DOM v-for. fruit.sort(), .
:
v-for="fruit in fruits.map(f => f).sort()", , . : 1) fruits.map(f => f) , , fruits, 2) .
:
, (, , , ). .
{
...Other component properties...
methods: {
sorted(arr) {
return arr.map(e => e).sort()
}
}
...Other component properties...
}
:
Vue 1.x, (v-for="fruit in fruits | orderBy", ({{ }}) Vue 2.x Vue .
- , , , , lodash orderBy(...).
{
...Other component properties...
computed: {
sortedFruits() {
return this.fruits.map(f => f).sort()
}
}
...Other component properties...
}
, .
: , .