Vue 列表與表格高亮設置
- 2020 年 3 月 4 日
- 筆記
點擊li 元素設置高亮的方法
<li v-for="(item,index) in lists" :key="index" :class="{ activeLi: currentLi == item }" @click="handleClick(index)" class="pointer"> {{item}} </li> handleClick(index) { let list = this.lists[index]; this.currentLi = list },.activeLi{ background:#ecf5ff; }表格的高亮可以設置 highlight-current-row
<el-table :data="tableData" border @row-click="handleRowClick" highlight-current-row >
如果進入頁面默認某一行高亮可以使用 setCurrentRow()方法
為el-table 設置ref="table" 假如設置第二行高亮
this.$refs.table.setCurrentRow(this.tableData[1]);
