vue2组件props;computed监控变量,watch执行方法
props: { mesData:{ type: Object, // 接受父组件值 required: true, }, tableLod:{ type: Function, // 接收父组件方法 required: true, }, }, computed: { isMesData() { return this.mesData // 将值装载到方法中 } }, watch: { isMesData(row) { this.$nextTick(()=>{ // 异步更新DOM数据 this.form.setFieldsValue(pick(row,'setsNo','serialNumber','weldingStatus','routeCode')) //将父组件的值装载到from表单中(建议先用Object拷贝) }) } },
methods: {
colse() {
this.mesColse(); // 执行父组件方法
},
}
- ref用法
父组件
<modal ref="modalTable"></modal>
父组件js
showProcessRoute: function (record) { this.$refs.modalTable.show(record); },
子组件
show (record) { this.currentRecord= record; this.visible = true; this.loadData(1); },
本文来自博客园,作者:就沈呗,转载请注明原文链接:https://www.cnblogs.com/ruoyushen/p/17036444.html