1. 程式人生 > >element中通過js觸發按鈕的點選事件

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