I have a component with props ans I want to modify the value from false to true but I have a message form chrome console
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders
In the parent component I have a function (myFunction) who take one argument( value ).
I need to keep my argument like this, but I also need to retrieve the value of the emit from the child component to change the value of myData without mutate the props in child.
https://codesandbox.io/s/distracted-wiles-w8vwf
<template>
<div>
<p>The number is {{number}}</p>
<Child :MyProp="myData" @on-click-btn="myfonction(5)"/>
</div>
</template>
<script>
import Child from "./components/Child.vue";
export default {
data() {
return {
myData: 'button',
number: 1
};
},
components: {
Child
},
methods: {
myfonction(value) {
this.number = value;
}
}
};
</script>
thanks