微信小程序根据内容不同显示不同的颜色
//首先创建fifg.wxs文件
// 反馈类型过滤
var unit = {
typeFilter: function (item) {
var background ;
switch (item) {
case "法律法规":
background = '#576DF3'
break;
case "部门规章":
background = "#57C1F3";
break;
}
return background;
}
}
module.exports = {
typeFilter: unit.typeFilter
}
//在wxml中引入
<wxs module="unit" src="./flfg.wxs"></wxs>
//使用
<text class="textbg" style="background:{{unit.typeFilter(item.Category)}}">{{item.Category}}</text>