第一次跳转到页面setData能正常渲染,退出页面重新进入后setData渲染无效。日志打印是已经执行了这段代码。
//自动模式
if (app.getPattern() == 1) {
console.log(“自动”);
that.setData({
autBackageColor: that.data.modeOpen,
modeBackageColor: that.data.defaultColor,
disabled: true
});
}
//手动模式
else if (app.getPattern() == 0) {
console.log(“手动”);
that.setData({
autBackageColor: that.data.defaultColor,
modeBackageColor: that.data.modeOpen,
disabled: false
});
}
<view class=“button-container”>
<view class=“ac-button-container”>
<view class=“ac-button” style=“background-color:{{modeBackageColor}}” bindtap=“mode”>
<image class=“button-image"src=”…/…/images/auto.png"></image>
</view>
<text>手动</text>
</view>
<view class=“ac-button-container”>
<view class=“ac-button” style=“background-color:{{autBackageColor}}” bindtap=“auto”>
<image class=“button-image” src="…/…/images/mode.png"></image>
</view>
<text>自动</text>
</view>
<view class=“ac-button-container”>
<view class=“ac-button” style=“background-color:{{powerBackageColor}}” bindtap=“power”>
<image class=“button-image” src="…/…/images/power.png"></image>
</view>
<text>{{openName}}</text>
</view>
</view>