【发布时间】:2019-10-27 06:13:16
【问题描述】:
我想在 Vuejs 中突出显示“@click”上的表格行。目前我在让它工作时遇到问题。
这是我的 html 模板,我在其中将活动类绑定到布尔值“isActive”。
<table
class="paginatedTable-table hide-table">
<thead class="paginatedTable-table-head">
<tr :class="{active: isActive}" class="paginatedTable-table-head-row">
<th
v-for="(column, key) in columns"
:key="key"
:class="column.align"
class="paginatedTable-table-head-row-header"
@click="sortTable(column)">
{{ column.label }}
<i
v-if="sortOptions.currentSortColumn === column.field"
:class="sortOptions.sortAscending ? icons.up : icons.down"
class="sort-icon" />
</th>
</tr>
我在 data 函数中声明 isActive 并设置为 false。
data() {
return {
width: '100%',
'marginLeft': '20px',
rowClicked: false,
filteredData: this.dataDetails,
isActive: false,
我将 isActive 设置为 true 的按钮单击功能
async selectRow(detail) {
this.isActive = true;
this.width = '72%';
this.rowClicked = true;
这部分我不太确定。这里我在 Sass 中设置 Css。
tr:not(.filters):not(.pagination-row) {
background-color: $white;
&.active{
background-color: $lc_lightPeriwinkle;
}
【问题讨论】:
标签: javascript html vue.js