wx.navigateTo 跳转第二次进入页面setData渲染无效
发布于 5 年前 作者 xiuyinggao 6940 次浏览 来自 问答

第一次跳转到页面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>

1 回复

生命周期使用onShow,接口加时间戳标识,我是这么解决的

回到顶部