收藏
回答

关于动态添加类名出错

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 工具 2.6.4.38 2.2.2

<wxml  --片段>

<text class="{{current == 0?'cpoint':'point'}}"></text>

<text class="{{current == 1?'cpoint':'point'}}"></text>

<text class="{{current == 2?'cpoint':'point'}}"></text>


<js  --片段>

data:current:0


var oldCurrent = this.data.current;

var newCurrent = (oldCurrent - 1) < 0 ? oldCurrent + 2 : oldCurrent - 1;

console.log(newCurrent);

this.setData({

current: newCurrent

})


问题:上面三个text标签在每次调用js里的方法之后只有类名发生改变的两个被添加上类名,在类名应该是point->point 时该标签没有添加上类名,问是什么原因,应该如何解决,求大神指点~

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容