I have a component similar to this one:
<template>
<div>
<p>Current coordinates: <strong>{{ coords }}</strong></p>
<button type="button" @click="updateCoords">
</div>
</template>
<script>
export default {
props: {
coords: {
type: Array,
required: true
}
},
setup(props) {
const updateCoords = () => {
props.coords = [38.561785, -121.449756]
// props.coords.value = [38.561785, -121.449756]
}
return { updateCoords }
},
}
</script>
I attempted to update the prop coords
value using the updateCoords
method but encountered an error message:
Uncaught TypeError: Cannot set properties of undefined (setting 'coords')
How can I correctly update the prop value in my situation?