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);
 },

 

posted @ 2023-01-09 11:18  就沈呗  阅读(445)  评论(0编辑  收藏  举报