Reuse Modal with VueJS 2

我与影子孤独终老i 提交于 2019-12-14 02:08:12

问题


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:


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.



来源:https://stackoverflow.com/questions/47092782/reuse-modal-with-vuejs-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!