1、views層
父組件:
<el-dialog title="編輯活動" :visible.sync="dialogCreateVisible" :close-on-click-modal="false" width="70%" :append-to-body="true" @dialogClose="dialogClose">
<activies-create :formData.sync="createForm" @cancelCreate="cancel" @okCreate="ok" />
</el-dialog>
補充:
通過.sync
實現數據雙向綁定
, 從而同步父子組件數據
通過數據的雙向綁定, 父組件可以修改子的數據, 子組件也可以修改父的數據
2、methods(數據處理)
父組件:(初始聲明)
//Object(對象--多個參數)
createForm:{
sellerId: 0,
activityid: 0
}
//String(一個參數)
currentSellerId: 0
子組件
props
接受參數watch
監聽formData
中值的變化
immediate:
true 將立即以表達式的當前值觸發回調handle:
watch中需要具體執行的方法deep:
需要監聽的數據的深度,一般用來監聽對象中某個屬性的變化
props:{
formData: Object
},
watch: {
formData: {
immediate: true,
handler (val) {
this.sellerId = val.sellerId;
this.activityid = val.activityid;
this.getList();
},
deep: true
}
}