vue根据状态改变文字颜色

html部分
 <template slot-scope="scope"><span :style="classObje(scope.row.id)" >{{scope.row.id}}</span></template>
js部分
computed: {
    classObje() {              
                return (id) => { // 使用JavaScript闭包,进行传值操作
                    console.log(id)
                    
                    if (id === 77){
                        return {'color':'red'}
                    } 
                    else if (id === 78){
                        return {'color':'blue'}
                    } 
                    else if (id === 79){
                        return {'color':'yellow'}
                    } else if (id === 80){
                        return {'color':'#41b883'}
                    }
                        
                }
            }
 
 
  },
正道的光终将来临,当太阳升起的时候,光芒总会普照大地温暖人间。些许的阴霾也终会有被阳光洒满的一天
原文地址:https://www.cnblogs.com/sjruxe/p/14966828.html