Answer the question
In order to leave comments, you need to log in
Screen resolution condition in Vue.js?
Good afternoon!
Can you please tell me how to correctly write an inline condition in the component: If the screen width is more than 700, then define :item-size="46", if the width is less than 699, then :item-size="56" ?
Answer the question
In order to leave comments, you need to log in
:item-size="itemSize"
data: () => ({
itemSize: null,
}),
methods: {
onResize() {
this.itemSize = document.documentElement.clientWidth > 700 ? 46 : 56;
},
},
created() {
window.addEventListener('resize', this.onResize);
this.onResize();
},
beforeDestroy() {
window.removeEventListener('resize', this.onResize);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question