Answer the question
In order to leave comments, you need to log in
Vue lodash.shuffle for a list?
Codesandbox ShuffleList.vue
There is a list with animation lodash.shuffle:
<template>
<div id="filter">
<button v-on:click="shuffle">Перемешать</button>
<transition-group
name="list"
mode="out-in"
tag="ul"
class="catalog-list">
<li
:key="index"
v-for="(item, index) in items">
<h3>{{ item.name }}</h3>
<span>{{ item.price }}</span>
</li>
</transition-group>
</div>
</template>
<script>
import _shuffle from "lodash.shuffle";
export default {
name: "FilterList",
data() {
return {
items: [
{ name: "Name 1", price: "200" },
{ name: "Name 2", price: "100" },
{ name: "Name 3", price: "5" }
]
};
},
methods: {
shuffle() {
this.items = _shuffle(this.items);
}
}
};
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question