好吧,我正在尝试在Vue中更改"变量"的值,但是当我单击按钮时,它们会在控制台中抛出一条消息:
[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"
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决这个问题......
我的file.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>
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我吗?谢谢