vue this.$refs使用方法

 
/** 修改按钮操作 */
    handleUpdate(row) {
      //调用组件announce-form中的handleUpdate方法
      this.$refs.modalForm.handleUpdate(row);
    },

 

<el-button size="mini" v-if="scope.row.status==0 || scope.row.status==2" type="text" icon="el-icon-edit"
                     @click="handleUpdate(scope.row)" v-hasPermi="['announce:announce:edit']">修改</el-button>
<announce-form ref="modalForm" @ok="handleListChange"></announce-form>

import AnnounceForm from './AnnounceForm';
components: {
      AnnounceForm,
  },
 
  name: 'AnnounceForm',
    

/** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      alert("handleUpdate")
      const id = row.id
      getById(this.url.getById, id).then(response => {
        this.form = response.data

        this.$set(this.form, 'timeRange', [new Date(this.form.startTime), new Date(this.form.endTime)])

        this.open = true
        this.title = '修改巡察公告'
      })
    }

 

posted @ 2022-05-24 14:43  aaa111js  阅读(1118)  评论(0编辑  收藏  举报