element中通过js触发按钮的点击事件

vue:

<el-button type="primary" @click="dataDocking2()">批量处理</el-button>(通过总按钮来触发下边表格按钮的事件)

<el-table
  :data="dataDockingTable"
  tooltip-effect="dark"
  style="width: 100%"
  @selection-change="handleSelectionChange">

<el-table-column
  :resizable="isResizable"
  label="操作"
>
  <template slot-scope="scope">
    <el-button  size="mini" :id="scope.row.vehicleId"  @click.native="dataDockingComplate(scope.row)">对接完成</el-button>
  </template>
</el-table-column>
</el-table>

js方法:(焦点是只能有一个地方被点中的,不可能同时被点中)

handleSelectionChange(val) {
  this.terminalNumbers = val;(直接返回的是多选行的总的对象构成的数组);
},
dataDocking2(){
  if(this.terminalNumbers != null && this.terminalNumbers.length != 0){
    this.terminalNumbers.forEach(o=>{
      document.getElementById(o.vehicleId).click();
    })
  }

猜你喜欢

转载自blog.csdn.net/qq_39692513/article/details/83046855