HarmonyOS 鸿蒙Next Text组件的.enableDataDetector(true)属性设置无效
HarmonyOS 鸿蒙Next Text组件的.enableDataDetector(true)属性设置无效
Text的.enableDataDetector(true)属性设置无效,帮看下还需要哪些设置吗?我用的真机环境测试
文档地址: https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-text-V5#enabledatadetector11
```javascript
[@Entry](/user/Entry)
[@Component](/user/Component)
struct Index {
@State message: string = 'asdfasdlfkjsdlfkjasdfld ssafd http://www.baidu.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%')
}
}
更多关于HarmonyOS 鸿蒙Next Text组件的.enableDataDetector(true)属性设置无效的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
您可以参考如下demo:
@Entry
@Component
struct Index {
@State message: string =
'asdfasdlfkjsdlfkjasdfld ssafd http://www.baidu.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%')
}
}
更多关于HarmonyOS 鸿蒙Next Text组件的.enableDataDetector(true)属性设置无效的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html