111
rated 0 times
[
114]
[
3]
/ answers: 1 / hits: 12588
/ 3 Years ago, thu, november 11, 2021, 12:00:00
I have like this component:
<template>
<div>
<p>Current coords: <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 tried update prop coords
value with updateCoords
method but I get error message:
Uncaught TypeError: Cannot set properties of undefined (setting
'coords')
How I can correctly update props value in my case?
More From » vue.js