我试图在Vue中更改"variable"的值,但当我点击按钮时,他们会在控制台中弹出一条消息:
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "menuOpen"
我不知道如何解决这个问题...
我的档案.vue:
<template>
<button v-on:click="changeValue()">ALTERAR</button>
</template>
<script>
export default {
name: 'layout',
props: [ 'menuOpen' ],
methods: {
changeValue: function () {
this.menuOpen = !this.menuOpen
}
},
}
</script>
有人能帮我吗?谢谢