切换字体的颜色
<!-- index.wxml --> <view class="container"> <text class="{{color}}" catchtap="click">点击文字</text> </view> <!-- index.wxss --> .window-red{ color: gold; } <!-- index.js --> var flag = true; var color = 'window'; Page({ click:function(){ if(flag){ color = "window-red"; flag = false; }else{ color = "window" flag = true; } this.setData({ color }) }, }