Vue子組件修改父組件傳的值

Vue父子間傳值

報錯

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: "selectType"

原因:父組件傳給子組件的值,在子組件當中重新賦值

1、父組件:傳值

2、子組件用prop接收

 

如果要對傳入的值從新賦值

需要在data裏面給他一個初始值

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章