伪代码如下:
<text :style="testStyle">{{ totalAmount.in }}</text>
computed: {
testStyle() {
return {
color: 'red'
};
}
},
最终编译的结果:
<text style="[object object]">0</text>
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows11
HBuilderX类型: 正式
HBuilderX版本号: 4.07
第三方开发者工具版本号: 1.06.2401020
基础库版本号: 3.3.4
项目创建方式: HBuilderX
伪代码如下:
<text :style="testStyle">{{ totalAmount.in }}</text>
computed: {
testStyle() {
return {
color: 'red'
};
}
},
最终编译的结果:
<text style="[object object]">0</text>
<text :style="testStyle">{{ totalAmount.in }}</text>
computed: {
testStyle() {
return {
color: 'red'
};
}
},
<text style="color:red">0</text> <text style="[object object]">0</text>
在组件上使用:style动态绑定样式时,如果在computed中返回的是对象,则最终编译的值是[object object]
m***@qq.com
多谢了,我也调到类似的问题了,:style="object",在H5显示正常,打包成安卓老是不能更新视图,百思不得其解,看了大佬的回复,茅塞顿开。
2026-01-18 00:53