HarmonyOS Span内边距不生效

Text() {
  Span(this.text)
    .height('100%')
    .padding({ left: 8.5, right: 8.5 })

  ImageSpan($r('app.media.search_tag_clear'))
    .width(16)
    .aspectRatio(1)
    .margin({ left: 12.5 })
    .onClick(() => {
      PageRouter.openUrl(DFZXConstantsRouter.searchPage, { 'index': this.index },
        (result: Object, prePagePath: string, prePageParam: Object) => {
          this.configData(result as Record<string, Object>)
          console.log(JSON.stringify(result))
        })
      // PageRouter.openUrl(DFZXConstantsRouter.searchPage,{'defaultSearchWordModel':this.defaultSearchWordModel},()=>{},{launchMode:LaunchMode.POP_TO_SINGLETON,animated:true})
    })
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.

如上代码.padding({left:8.5,right:8.5})再Span里面并没有生效。

HarmonyOS
2025-01-09 17:47:59
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

span规格上不直接支持padding和margin,采用自绘制span的方式实现padding和margin的功能,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-universal-styled-string-V5#示例6

分享
微博
QQ
微信
回复
2025-01-09 19:12:35


相关问题
HarmonyOS text内边如何去掉
281浏览 • 1回复 待解决
如何设置组件的内边尺寸?
921浏览 • 1回复 待解决
HarmonyOS 怎么取消 Text的默认内边
981浏览 • 1回复 待解决
HarmonyOS margin生效
1142浏览 • 1回复 待解决
HarmonyOS expandSafeArea生效
1024浏览 • 1回复 待解决
HarmonyOS @Observed生效问题
1253浏览 • 1回复 待解决
HarmonyOS margin生效问题
735浏览 • 1回复 待解决
HarmonyOS targetSpace生效问题
566浏览 • 1回复 待解决
abiFilters配置生效
995浏览 • 1回复 待解决
HarmonyOS Web组件borderRadius生效
735浏览 • 1回复 待解决
HarmonyOS Stack 里 align生效
699浏览 • 1回复 待解决
HarmonyOS photoViewPicker智能推荐生效
946浏览 • 1回复 待解决
HarmonyOS 关于onKeyEvent生效问题
1039浏览 • 1回复 待解决
HarmonyOS stack设置圆角生效
664浏览 • 1回复 待解决
HarmonyOS 单例模式生效
554浏览 • 1回复 待解决
HarmonyOS hitTestBehavior.block生效
921浏览 • 1回复 待解决
HarmonyOS Panel 设置 borderRadius 生效
1462浏览 • 1回复 待解决
ConstraintSize尺寸设置生效
2870浏览 • 1回复 待解决