2
まあ、私はVueの中に、「変数」の値を変更しようとしているが、私は、彼らは、コンソールにメッセージを投げるボタンをクリックしたとき:代わりに、小道具の値に基づいてデータまたは計算されたプロパティを使用します。 VueのJS
[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"
私はこれを解決する方法が分かりません問題...
マイ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>
いずれかが私を助けることができますか?ありがとう
私はこれをやったと思って、多くのチュートリアルを見て、得られなかった!ありがとう、相棒。 –
あるいは、v2.3から '.sync'修飾子を使うことができます:https://vuejs.org/v2/guide/components.html#sync-Modifier – giannoug