Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

table表格中某个表格要依据后台传的id数据做正负判断。

就像下面这种,我现在要根据这条数据里面的id值的前四位做判断,例如:dev_id: "140134000000000004",这里前四位就是1401,我要截取这个数据前四位再判断这条数据的无功值是不是负的,负的就标红。这种前端该怎么做?

  1. 电抗器无功值为负用红字(电容器设备id前四位为1402,电抗器设备id前四位为1401
<vxe-table-column field="q_score" min-width='100' title="无功得分">
    <template v-slot="{ row }">
      <span :class="[row.q_score !== 100 ? 'red' : 'black']">
        {{ row.q_score }}
      </span>
    </template>
  </vxe-table-column>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

class三目运算解决。

<vxe-table-column field="q_value" min-width='120' title="无功值">
      <template v-slot="{ row }">
      <span :class="[row.dev_id.substring(0, 4) == '1401' ? ( row.q_value < 0 ? 'red' : 'black' ) : 'error']">
        {{ row.q_value }}
      </span>
    </template>
</vxe-table-column>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...