I'm having trouble assigning values from a method to variables in HTML. Here's what I have in my code:
<b-card-text>X position {{xpos}}</b-card-text>
<b-card-text>Y position {{ypos}}</b-card-text>
I would like to assign values to xpos and ypos from the following method:
methods: {
show() {
const canvas = document.getElementById('canvasId')
canvas.addEventListener('click', event => {
const rect = canvas.getBoundingClientRect()
const x = event.clientX - rect.left - canvas.clientLeft
const y = event.clientY - rect.top - canvas.clientTop
const xpos = x
const ypos = y
})
},
When trying to access xpos and ypos, I encountered an error:
'xpos' is assigned a value but never used
'ypos' is assigned a value but never used
Could you please advise me on how to properly assign values from this method?