Answer the question
In order to leave comments, you need to log in
How to access the DOM element in such a situation?
HTML:
<figure v-show = "( page === 'calculation ')">
<canvas id="canvas"></canvas>
</figure>
var vm = new Vue ({
data: {
page: 'order'
},
methods: {
changeActivePage: function ( page ) {
this.page = page;
// В этот момент <figure> ещё в состоянии display:none, поэтому оказывается, что размеры <canvas> нулевые
console.log( picture ) // <canvas ... width="0" height="0">
...
}
}
}
var picture = document.getElementById ( 'canvas' );
vm.changeActivePage( 'calculation' );
Answer the question
In order to leave comments, you need to log in
You have already been answered above correctly, I will only add:
https://vuejs.org/v2/api/#Options-Lifecycle-Hooks
https://vuejs.org/v2/api/#mounted
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question