HarmonyOS Text组件的.enableDataDetector\(true\)属性设置无效?

Text的.enableDataDetector(true)属性设置无效,帮看下还需要哪些设置吗?

文档地址:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-text-V5\#enabledatadetector11

相关代码:

@Entry
@Component
struct Index {
  @State message: string = 'asdfasdlfkjsdlfkjasdfld ssafd http://www.huawei.com asdfdsafdfsd hhh@hh.com  asdfsdfsadds 010-85868187 asdfsdfdsf';
  build() {
    RelativeContainer() {
      Text(this.message)
        .enableDataDetector(true) //设置后无效,没能识别出URL/email/电话等
        .id('HelloWorld')
        .fontSize(20)
        .fontWeight(FontWeight.Bold)
        .alignRules({
          center: { anchor: '__container__', align: VerticalAlign.Center },
          middle: { anchor: '__container__', align: HorizontalAlign.Center }
        })
    }
    .height('100%')
    .width('100%')
  }
}
阅读 471
1 个回答

可以参考如下demo:

@Entry
@Component
struct Index {
  @State message: string =
    'asdfasdlfkjsdlfkjasdfld ssafd http://www.huawei.com asdfdsafdfsd hhh@hh.com asdfsdfsadds 010-85868187 asdfsdfdsf';
  build() {
    RelativeContainer() {
      Text(this.message)
        .enableDataDetector(true)
        .id('HelloWorld')
        .copyOption(CopyOptions.InApp)
        .fontSize(20)
        .fontWeight(FontWeight.Bold)
        .alignRules({
          center: { anchor: '__container__', align: VerticalAlign.Center },
          middle: { anchor: '__container__', align: HorizontalAlign.Center }
        })
    }
    .height('100%')
    .width('100%')
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进