父組件→子組件 <div class="father"> <child :inputName="name"> </div> <div class="child"> {{inputName}} </div> 通過props接受數據 (1)props: { inputName: String, required: true } (2)props: ["inputName"] 子組件→父組件 子組件使用 $emit('方法名','其他參數')傳遞 子組件: <input type="button" value="點擊觸發" @click="childClick"> data:{ childdata:'hello' } methods:{ childClick(){ this.$emit('goFather',childdata) } } 父組件: <child @goFather="fatherFunction"></child> methhods:{ fatherFunction(content){ console.log(content) //content是傳遞上來的數據 } } 父組件調用子組件的方法 父組件: <div @click="parentMethod"> <children ref="child"></children> </div> this.$refs.child.childMethods(); //childMethods()是子組件中的方法 父子組件之間修改數據 this.$children.msg='123' this.$parent.msg='456'