mirror of
https://gitee.com/ShopeX/ECShopX_mobile-frontend
synced 2026-08-05 20:35:50 +08:00
style: 挂件内联样式 key 统一为 kebab-case
- helper getGlobalBaseStyle: paddingTop/Bottom/Left/Right → padding-top 等 - location-module 导航项: borderRadius/backgroundColor/paddingLeft/Right → border-radius 等 Made-with: Cursor
This commit is contained in:
8
docs/changelog/2025-03-13-style-keys.md
Normal file
8
docs/changelog/2025-03-13-style-keys.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# 样式 key 统一为 kebab-case
|
||||
|
||||
## 变更摘要
|
||||
|
||||
- **helper.js**:`getGlobalBaseStyle` 中边距样式由 camelCase 改为 kebab-case(`paddingTop` → `padding-top` 等)。
|
||||
- **location-module**:导航项内联样式 `borderRadius`、`backgroundColor`、`paddingLeft`/`paddingRight` 改为 `border-radius`、`background-color`、`padding-left`/`padding-right`。
|
||||
|
||||
便于小程序等环境正确解析内联样式。
|
||||
@@ -122,19 +122,19 @@ export function getGlobalBaseStyle(baseStyle) {
|
||||
|
||||
// 处理边距
|
||||
if (baseStyle.paddedt !== undefined && baseStyle.paddedt !== null) {
|
||||
style.paddingTop = Taro.pxTransform(baseStyle.paddedt)
|
||||
style['padding-top'] = Taro.pxTransform(baseStyle.paddedt)
|
||||
}
|
||||
|
||||
if (baseStyle.paddedb !== undefined && baseStyle.paddedb !== null) {
|
||||
style.paddingBottom = Taro.pxTransform(baseStyle.paddedb)
|
||||
style['padding-bottom'] = Taro.pxTransform(baseStyle.paddedb)
|
||||
}
|
||||
|
||||
if (baseStyle.paddedl !== undefined && baseStyle.paddedl !== null) {
|
||||
style.paddingLeft = Taro.pxTransform(baseStyle.paddedl)
|
||||
style['padding-left'] = Taro.pxTransform(baseStyle.paddedl)
|
||||
}
|
||||
|
||||
if (baseStyle.paddedr !== undefined && baseStyle.paddedr !== null) {
|
||||
style.paddingRight = Taro.pxTransform(baseStyle.paddedr)
|
||||
style['padding-right'] = Taro.pxTransform(baseStyle.paddedr)
|
||||
}
|
||||
|
||||
// 处理背景
|
||||
|
||||
@@ -64,7 +64,7 @@ export default function WgtLocationModule(props) {
|
||||
const navitemarea = base.navitemarea || {}
|
||||
return {
|
||||
...getGlobalBaseStyle(navitemarea),
|
||||
borderRadius: base.navitemradius ? Taro.pxTransform(base.navitemradius) : 0
|
||||
'border-radius': base.navitemradius ? Taro.pxTransform(base.navitemradius) : 0
|
||||
}
|
||||
}, [base.navitemarea, base.navitemradius])
|
||||
|
||||
@@ -74,11 +74,11 @@ export default function WgtLocationModule(props) {
|
||||
return {
|
||||
height: Taro.pxTransform(base.navitemheight || 40),
|
||||
color: textColor,
|
||||
backgroundColor: isActive
|
||||
'background-color': isActive
|
||||
? item.navitemactivebg || 'transparent'
|
||||
: item.navitembg || 'transparent',
|
||||
paddingLeft: `${Taro.pxTransform(base.navitemmargin || 0)}`,
|
||||
paddingRight: `${Taro.pxTransform(base.navitemmargin || 0)}`
|
||||
'padding-left': `${Taro.pxTransform(base.navitemmargin || 0)}`,
|
||||
'padding-right': `${Taro.pxTransform(base.navitemmargin || 0)}`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user