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%)'
}
}
}
}
标签:case,Vue,return,computed,gradient,90deg,0%,传值,linear 来源: https://www.cnblogs.com/lzuku/p/15535901.html