LabelComponent.ets 1.23 KB
import LinkList from '@ohos.util.List';
import { LabelBean } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { Logger } from 'wdKit';

import { EmptyComponent } from './EmptyComponent';

const TAG = 'LabelComponent';

/**
 * 标题/标签组件(暂时仅展示主标题,不展示子标题)
 * LABEL-01
 * 重磅推荐/精选/电视剧/电影/综艺/短剧/更多>/
 * 1.只有一个LABEL主标题(如重磅推荐)
 * 2.左右共两个LABEL(左边【电影】是主标题/右边【上海电影节】是子标题)
 */
@Component
export struct LabelComponent {
  @State label: string = '';

  build() {
    Row() {
      Text(this.label)
        .width(CommonConstants.FULL_PARENT)
        .padding({
          left: $r('app.float.main_margin'),
          right: $r('app.float.main_margin'),
          top: $r('app.float.label_margin_top'),
          bottom: $r('app.float.label_margin_bottom')
        })
        .fontSize($r('app.float.normal_text_size'))
        .fontWeight(FontWeight.Bold)
        .maxLines(1)
        // .backgroundColor(Color.Yellow)
        .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
    }
    .width(CommonConstants.FULL_PARENT)
    .justifyContent(FlexAlign.Start)
  }
}