Answer the question
In order to leave comments, you need to log in
Condition does not work || or. What am I doing wrong?
created() {
this.getUserRecipes();
window.addEventListener('resize', this.countRanks);
},
computed: {
ranks() {
const ranks = [];
this.selectedRecipes.forEach((item, index) => {
const rank = Math.floor(index / (this.countRanks() || 4));
if (!ranks[rank]) {
ranks[rank] = [];
}
ranks[rank].push(item);
});
return ranks;
},
},
methods: {
countRanks(e) {
const screenWidth = e.target.innerWidth;
if (screenWidth >= 992 && screenWidth < 1200) {
return 3;
}
if (screenWidth >= 768 && screenWidth < 992) {
return 2;
}
if (screenWidth > 0 && screenWidth < 768) {
return 1;
}
return 4;
},
const rank = Math.floor(index / ****)
countRanks
it should be the number that it will return.
Answer the question
In order to leave comments, you need to log in
1) The error is not in "||"
2) Also, this block is absolutely not needed, because in "countRanks ()" does not return a false value.
3) The error is described in plain text as "TypeError: Cannot read properties of undefined (reading 'target')" , all you need to do is open the translator.
Look closely at the method call.
const rank = Math.floor(index / (this.countRanks() || 4));
countRanks(e) {
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question