Answer the question
In order to leave comments, you need to log in
In which lifecycle hook should the screen size check be done?
I want to add a class to an element on a mobile phone, how to do it right?
Answer the question
In order to leave comments, you need to log in
Looking what logic follows after check.
And somounted
mounted() {
this.$nextTick(function () {
// код будет вызван после того как будут отрисованы все дочерние компоненты
})
}
On any. You need a prototype\plugin\global mixin extension that will take care of this itself, and in the component just use it.
It makes no sense to write this logic in one component, because it will definitely be needed in another.
For example .
If you really want to, then you created
hang the handler on resize
(or better mediaQuery
addListener
\ onchange
time you have a specific breakpoint), destroyed
you must remove the handler on. The handler itself sets some variable in data
.
You should use CSS media queries .
It's good when the JS code is preparing data for display and processing it after user input, but knows nothing about how exactly this data will be displayed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question