Answer the question
In order to leave comments, you need to log in
How to filter by vue js/ vuex products?
Products Component:
<div class="create__item" v-for="item in getDocuments" :data-id="item._id">
<div class="create__name">{{ item.title }}</div>
<div class="create__price">{{ item.currentPrice }} рублей</div>
</div>
const currentDocuments = ref([])
const getDocuments = computed(() => {
currentDocuments.value = store.getters['document/getDocuments'].slice(startIndexForArray.value, endIndexForArray.value)
const num = store.getters['document/getDocuments'].length / 4
if (num === 0) return maxStep.value = num
if (num % 1 === 0) {
maxStep.value = num + 1
} else {
maxStep.value = Math.ceil(num)
}
return currentDocuments.value
})
getters: {
getDocuments(state) {
return state.documents
}
},
mutations: {
setDocuments(state, documents) {
if (Array.isArray(documents)) {
return state.documents = documents
} else {
return state.documents.push(documents)
}
},
},
const getFilterDocuments = computed(() => {
filterDocuments.value = store.getters['document/getDocuments'].filter(doc => doc.category === filter.value)
currentDocuments.value = filterDocuments.value.slice(startIndexForArray.value, endIndexForArray.value)
const num = filterDocuments.value.length / 4
if (num === 0) return maxStep.value = num
if (num % 1 === 0) {
maxStep.value = num + 1
} else {
maxStep.value = Math.ceil(num)
}
// if (props.item.category === filter.value) currentDocuments.value.push(props.item)
return currentDocuments.value
})
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