三元运算符---class及style的运用
1.style
<span
id="fund-tag"
:class="[scope.row.risktype == 'R1' ? 'active1' : scope.row.risktype == ('R2' || 'R3' || 'R4') ? 'active2' : scope.row.risktype == 'R5' ? 'active3' : '']">
{{ scope.row.risklevel }}
</span>
2.style
<span class='sTop' :style="{ color: Number(o.comparedPre > 0) ? '#F91E1E' : Number(o.comparedPre < 0) ? '#00A20F' : '' }">{{o.comparedPre | filterData}}</span>
//数字过滤
filters: {
filterData (data) {
return data === undefined || data === null || data === '-' ? '-' : data + '%'
}
},