Answer the question
In order to leave comments, you need to log in
How to use computed inside watch in vue + vuex?
Hello, I want to use the computed property (analogous to vmin) in watch. But for some reason, this.getMinSide does not work (if you put just numbers, then everything is ok ... everything is also ok in chrome debugging) What goes wrong))?
computed: {
getMinSide() {
if (
document.documentElement.clientHeight <
document.documentElement.clientWidth
) {
return document.documentElement.clientHeight;
} else {
return document.documentElement.clientWidth;
}
},
},
watch: {
"$i18n.locale": () => {
document.getElementById("frame").style.width =
(document.getElementById("frame").childNodes[0].scrollWidth * 100) /
this.getMinSide +
"vmin";
},
},
Answer the question
In order to leave comments, you need to log in
Everything related to dom is not reactive, getMinSide will be calculated once and that's it. Recalculate on the resize event.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question