Answer the question
In order to leave comments, you need to log in
How to get window.screen.width in computed on every change?
I have a computed property that is responsible for the number of rows for cards. And this property should return the number of rows depending on the width of the window, the problem is that this only works 1 time, when the page is updated, and I need to receive an update of the computed property every time the width changes through devtools, even by 1 px. Help solve the problem))
countRanks() {
const screenWidth = window.screen.width;
console.log(screenWidth);
if (screenWidth >= 992 && screenWidth < 1200) {
return 3;
}
if (screenWidth >= 768 && screenWidth < 992) {
return 2;
}
if (screenWidth > 0 && screenWidth < 768) {
return 1;
}
return 4;
},
},
<p>countRanks</p>
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