效果图:

 代码:

1.给div绑定一个动态的style

:style="bgColorFor(item)

2.方法

methods:{
    //随机渐变色
    bgColorFor(item){
      let R = Math.floor(Math.random() * 130+110);
      let G = Math.floor(Math.random() * 130+110);
      let B = Math.floor(Math.random() * 130+110);
      return {
        background: 'linear-gradient(to right, #fff, rgba(' + R + ',' + B + ',' + G + ',0.5))'
      };
    }
  }

参考菜鸟教程官网

最后一位是透明度 

更多推荐

css 随机渐变色