switch的disabled有三个条件,disabled是实现了,但我希望视觉上组件被禁用时有变化。
例如再class中增加一个属性“gray”,不禁用时则没有属性“gray”,来实现视觉变化。这种多条件渲染怎么写好?
<switch disabled="{{item.isChanged || isCloudCalling || item.responsiblePhoneNumber!=staffData.staffPhoneNumber}}" class="margin-left" checked="{{item.isComplete}}" data-id="{{item._id}}" data-type="{{item.workType}}" data-index="{{index}}" bindchange="bindClosedLoop" />
推荐用一些组件库,更方便一些,比如vant的库。参考:https://youzan.github.io/vant-weapp/#/switch
可以用wxs里定义一个方法,返回不同状态下 class 名
wxs文档:https://developers.weixin.qq.com/miniprogram/dev/reference/wxs/