I'm calculating the container width and height using computed property and assigns it to the canvas in vue js.
export default {
...
computed: {
dimensions() {
return document.getElementById(
'canvas-container'
);
},
},
...
}
<div id="canvas-container">
<canvas
v-bind:id="id"
:height="dimensions.clientHeight"
:width="dimensions.clientWidth"
></canvas>
</div>
But the issue is that I'm getting an undefined error like: cannot read the property clientHeight of null.
How can I avoid this.?
canvas-container?