In vue, how to give a color according to the size of a number value.

I now have a set of data that is looped through v-for, in which a data is given red when it needs to be greater than zero and green when it is below zero. What are the ways to implement the code?
I want to write it in the loop body and make a judgment about the binding style, but I don"t know how to implement it.

Mar.10,2021

// template
<div v-for="item in list" :style="'color:'+(item.value>0?'red':'green')+';'">{{item.name}}</div>

// js
data () {
    return {
        list: [{
            name: 1,
            value: 1
        }, {
            name: 2,
            value: -1
        }, {
            name: 3,
            value: 3
        }]
    }
}

Update:
change the background color when you click

// template
<div v-for="(item, index) in list" <!-- vue1.0 itemindex -->
      @click="clickHandler(index)"
      :class="{active: index === activeIndex}"
      :style="'color:'+(item.value>0?'red':'green')+';'">{{item.name}}</div>

// js
data () {
    return {
        list: [{
            name: 1,
            value: 1
        }, {
            name: 2,
            value: -1
        }, {
            name: 3,
            value: 3
        }],
        activeIndex: -1
    }
},

methods: {
    clickHandler (index) {
        this.activeIndex = index
    }
}

// css
.active {
  background-color: yellow;
}

just make the style dynamic


class
:class='[item.value>0?"green":"red"]'

official document: ide/class-and-style.html" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c31461-33d4b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c31461-33d4b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?