TextInput组件,为了不响应点击事件,设置了enabled(false)属性,但同时给值了之后,颜色还是placeholder的颜色,不是font的颜色,如何处理
代码如下:
TextInput({ placeholder: "您的出发地", text: this.baseAddress })
.commonTextInputStyle(14, $r("app.color.color33"), 14, $r("app.color.colorC6"))
.padding({ left: 10, right: 0 })
.enabled(false)
@Extend(TextInput)
function commonTextInputStyle(fontSize: Length, fontColor: ResourceColor, placeholderFontSize: Length,
placeholderFontColor: ResourceColor) {
.layoutWeight(1)
.fontSize(fontSize)
.borderRadius(0)
.fontColor(fontColor)
.maxLines(1)
.caretColor($r("app.color.themeColor"))
.caretStyle({ width: 2 })
.placeholderFont({ size: placeholderFontSize })
.placeholderColor(placeholderFontColor)
.padding({ left: 0, right: 0 })
.backgroundColor(Color.Transparent)
}
可以通过设置hitTestBehavior(HitTestMode.None)让TextInput不生效点击事件