vue根据状态改变文字颜色

时间:2021-07-03 22:22:53   收藏:0   阅读:229
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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!