Vue - 通过computed传值判断类型

通过返回函数,判断参数内容。

<view class="item" :style="{'background':cardBg(index)}" </view>

computed: {		
  cardBg() {
     return function(index) {
      switch (index) {
        case 0:
          return 'linear-gradient(90deg, #32AAFA 0%, #9FD8FF 100%)'
        case 1:
          return 'linear-gradient(90deg, #FF9F2C 0%, #FFC784 100%)'
        case 2:
          return 'linear-gradient(90deg, #23AB23 0%, #91F391 100%)'
        case 3:
          return 'linear-gradient(90deg, #7E23AB 0%, #D691F3 100%)'
			}
		}
	}
}
上一篇:ABC228D - Linear Probing


下一篇:sklearn代码23 6-线性回归岭回归 套索回归比较