I am having trouble resizing a DIV block in Vue3. Whenever I click the button, I receive an error message saying "Cannot read properties of undefined (reading 'style')". I know there is an issue with the JS part of the code, but I'm not sure how to correct it.
Here is the relevant HTML:
<div ref="block2">
<button v-on:click="changeWidth()"></button>
</div>
And here is the corresponding JavaScript:
methods: {
changeWidth:function()
this.$refs.block2.style.width = "150px";
}
}
The CSS styling for the DIV is as follows:
#block2{
position:absolute;
z-index:5000;
width:50px;
height:50px;
background-color: #7d7d7d;
transition: all .3s ease-in;
}
Any assistance would be greatly appreciated.