2

I see a reuse modal in JSFiddle use Vue version 1: https://jsfiddle.net/_kemar/d3jecL8n/

But when I change to Vue version 2, it can't work. How can I fix this? https://jsfiddle.net/chelsea39/awwk6v5h/1/

Error when updating to Vue2:

[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: "show"

Saurabh
  • 71,488
  • 40
  • 181
  • 244
KitKit
  • 8,549
  • 12
  • 56
  • 82

1 Answers1

0

The issue is that you are trying to change the show prop, which is passed from a parent component inside the child component. You can copy the show boolean into the child component data inside the child component lifecycle hooks and then you can modify it freely inside the child component.

Lassi Uosukainen
  • 1,598
  • 13
  • 22
  • I must say I am struggling a little bit with this as well. You can't simply make it a data property since 'show' will initially be false in the parent and changed to true upon a click or some other event. – Matthew Kirkley Jun 26 '18 at 15:09