Reuse Modal with VueJS 2

2019-07-15 06:47发布

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"

1条回答
聊天终结者
2楼-- · 2019-07-15 07:20

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.

查看更多
登录 后发表回答