情景大概是这样,antd表格一开始就显示一些内容,然后内容有个索引,需要达到的效果是索引为0的那行背景色为黄色。点击往上查看更多时候,表格往上插入30条数据,点击往下时候下面表格插入30数据。需要做的是固定0那行。大概原理就是记住0行移动前的位置移动后的位置,去掉移动前的颜色,加上移动后的颜色。
<template slot="indexNumber" slot-scope="text">
<span v-if="text > 0" style="color:#4FA74F;font-size:16px;">{{text}}</span>
<span v-if="text < 0" style="color:#f00;font-size:16px;">{{text}}</span>
<span
v-if="text == 0"
style="color:#4FA74F;font-size:30px;"
class="highLight"
>{{text}}</span>
</template>
this.$nextTick(() => {
this.last = document.getElementsByClassName("highLight")[0];
this.last.parentNode.parentNode.style =
"background: rgba(255,196,0,.62);text-align: center";
});
this.$nextTick(() => {
this.last = document.getElementsByClassName("highLight")[0];
this.last.parentNode.parentNode.style =
"background: rgba(255,196,0,.62);text-align: center";
});