我是大钊
我是大钊
  • 发布:2021-12-28 12:06
  • 更新:2021-12-28 21:17
  • 阅读:278

【报Bug】样式计算在H5和微信中是不同的

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows10

HBuilderX类型: 正式

HBuilderX版本号: 3.2.16

第三方开发者工具版本号: 3.2.16.20211122

基础库版本号: 什么基础库?

项目创建方式: HBuilderX

示例代码:

<template>
<view :style="imagebox">
<lqz-banner :AdvName="item.advName" :height="item.height+'px'" @click="clickView(item.options)"></lqz-banner>
</view>
</template>
computed: {
imagebox: function() {
let boxclass = {
height: this.item.height + 'px',
'margin-left': this.item.margin_left + 'px',
'margin-right': this.item.margin_right + 'px',
'margin-top': this.item.margin_top + 'px',
'margin-bottom': this.item.margin_bottom + 'px',
'padding-bottom': this.item.padding_bottom + 'px',
'padding-left': this.item.padding_left + 'px',
'padding-right': this.item.padding_right + 'px',
'padding-top': this.item.padding_top + 'px'
}
// #ifdef MP-WEIXIN
return JSON.stringify(boxclass);
// #endif
// #ifndef MP-WEIXIN
return boxclass;
// #endif
}
},

操作步骤:

<template>
<view :style="imagebox">
<lqz-banner :AdvName="item.advName" :height="item.height+'px'" @click="clickView(item.options)"></lqz-banner>
</view>
</template>
computed: {
imagebox: function() {
let boxclass = {
height: this.item.height + 'px',
'margin-left': this.item.margin_left + 'px',
'margin-right': this.item.margin_right + 'px',
'margin-top': this.item.margin_top + 'px',
'margin-bottom': this.item.margin_bottom + 'px',
'padding-bottom': this.item.padding_bottom + 'px',
'padding-left': this.item.padding_left + 'px',
'padding-right': this.item.padding_right + 'px',
'padding-top': this.item.padding_top + 'px'
}
// #ifdef MP-WEIXIN
return JSON.stringify(boxclass);
// #endif
// #ifndef MP-WEIXIN
return boxclass;
// #endif
}
},

预期结果:

多端相同

实际结果:

微信中和其他端不同

bug描述:

定义一个动态样式,在h5和APP中会自动引入样式 style,在微信中显示的是object。一个需要用字符串,一个需要用object

2021-12-28 12:06 负责人:无 分享
已邀请:
我是大钊

我是大钊 (作者)

应该不是uniapp的问题,是微信小程序不支持

DCloud_UNI_Anne

DCloud_UNI_Anne

小程序端不支持 classObject 和 styleObject 语法。文档

该问题目前已经被锁定, 无法添加新回复