语法:
Text(content?:string|resource)
1. 第一种方式 直接显示文本内容
string格式,在组件中写什么字符串,就会显示什么字符串
`Text('图片宽度')`
2. 第二种方式 读取本地资源文件
Resource格式,在限定词目录中写好中英文文本,在中文设备上显示中文,在英文设备上显示英文,实现一个国际化的效果。
`Text($r('app.string.pictureWidth'))`
报错:xxx is translated here but not found in the default locale.
限定词添加完目录,还报错的原因:在中文、英文限定词中添加后,没有在base目录下的string.json文件中添加。
>Text的属性
Text(this.message2)
.lineHeight(60)
.fontColor('red')
.fontSize(50)
.fontWeight(FontWeight.Bold)