Answer the question
In order to leave comments, you need to log in
How to keep track of Vue screen width?
There is a computed property whose value must come from the width of the screen. The question is how do I keep track of this value at all times.
isOpenAllFiltersWith(){
if(document.documentElement.clientWidth <= 500){
return true
}
else return this.isOpenAllFilters
},
Answer the question
In order to leave comments, you need to log in
Add a property to the component that will contain the screen width:
data: () => ({
width: 0,
...
}),
methods: {
updateWidth() {
this.width = window.innerWidth;
},
...
},
created() {
window.addEventListener('resize', this.updateWidth);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question