3

如何在ElementUI组件传递其他参数?

 3 years ago
source link: https://www.leixuesong.com/3869
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何在ElementUI组件传递其他参数?

WEB前端 Vue.js 2020年8月18日

在一个Vue的前端项目中,有一个页面共用了一个表格。当ElementUI表格单选后,除了能获取到当前这一列的数据,还希望能传自定义参数来区分当前哪个Tab。下面雷雪松带大家看一下如何在ElementUI组件传递其他参数。

ElementUI官方Demo写法:

<el-table :data="tableData" highlight-current-row @current-change="handleCurrentChange"></el-table>
handleCurrentChange(val) {this.currentRow = val; }

ElementUI组件传递其他参数写法:

<el-table :data="tableData" highlight-current-row @current-change="(currentRow, oldCurrentRow)=>handleCurrentChange(currentRow, oldCurrentRow,1)"></el-table>
handleCurrentChange(currentRow, oldCurrentRow,options) {this.currentRow = val;console.log(options) }

在ElementUI其他组件如果需要传自定义的参数也可以这样写。

来源:如何在ElementUI组件传递其他参数?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK