uni-app 编译为百度小程序环境后 页面中mapState数据到computed页面中没有渲染
uni-app 编译为百度小程序环境后 页面中mapState数据到computed页面中没有渲染
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Mac | 10.15.6 | HBuilderX |
### 示例代码:
```html
<!-- 控制章节目录加载 start -->
<view v-if="showMoreChapter" class="chapter-retract">
<view class="retract-btn" [@click](/user/click)="onShowMoreChapter">
<text class="retract-title">{{language.retractChapter}}</text>
<text class="iconfont-arrow-right retract-icon"></text>
</view>
</view>
<view v-else class="more-chapter" [@click](/user/click)="onShowMoreChapter">
<text class="more-title">{{language.moreChapter}}</text>
<text class="iconfont-arrow-right more-icon"></text>
</view>
computed: {
...mapState(['language', 'siteConfig', 'userInfo'])
}
操作步骤:
mapState接入store数据,并在结构层中使用
预期结果:
结构层中渲染
实际结果:
未渲染
bug描述:
编译为百度小程序环境后,页面中mapState数据到computed页面中没有渲染, 经过测试是3.260.37(最新)不匹配,3.250.41为正常
更多关于uni-app 编译为百度小程序环境后 页面中mapState数据到computed页面中没有渲染的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
问题已确认,预计在下一个 alpha 版本修复
更多关于uni-app 编译为百度小程序环境后 页面中mapState数据到computed页面中没有渲染的实战教程也可以访问 https://www.itying.com/category-93-b0.html
HBuilderX 3.1.6+ alpha 已修复
在uni-app 3.260.37版本中,百度小程序环境确实存在computed中mapState数据渲染异常的问题。这是该版本特有的兼容性bug,从你描述的3.250.41版本正常可以确认这一点。
建议的解决方案:
-
临时回退版本:将HBuilderX回退到3.250.41版本,这是目前最稳妥的解决方案。
-
替代方案:在等待官方修复期间,可以使用以下方式替代mapState:
computed: {
language() {
return this.$store.state.language
},
siteConfig() {
return this.$store.state.siteConfig
},
userInfo() {
return this.$store.state.userInfo
}
}