import backgroundTaskManager from '@ohos.backgroundTaskManager'
@Entry
@Component
struct StateCase {
@State message: string = '测试'
@State textEnable: boolean = false
@Styles pressTextStyle(){
.width(180)
.height(100)
.backgroundColor(0x00ffff)
}
@Styles
disTextStyle(){
// .width(180)
// .height(100)
.backgroundColor(Color.Red)
}
@Styles
inputFouceStyle() {
.backgroundColor(Color.Transparent)
.border({
color: Color.Red,
width: 1
})
}
@Styles
inputNorStyle() {
.backgroundColor(Color.Transparent)
.border({
color: Color.Red,
width: 0
})
}
build() {
Row() {
Column() {
TextInput()
.stateStyles(
{
focused: this.inputFouceStyle,
normal: this.inputNorStyle
}
)
TextInput()
.stateStyles(
{
focused: this.inputFouceStyle,
normal: this.inputNorStyle
}
)
Text(this.message)
.textAlign(TextAlign.Center)
.width(100)
.height(50)
// .backgroundColor('#ff00ff')
.stateStyles({
pressed: this.pressTextStyle,
disabled: this.disTextStyle
})
.enabled(this.textEnable)
Button('文本设置')
.onClick(() => {
this.textEnable = !this.textEnable
})
}
.width('100%')
}
.height('100%')
}
}
鸿蒙开发-stateStyles
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- Button 是什么 按钮(Button)是一种常见的组件,点击可以触发对应的操作,通常由文本或图标组成,也可以由...
- 导读 本指南为开发者提供了使用 Taro 框架开发鸿蒙原生应用的快速入门方法。Taro,作为一个多端统一开发框架,...
- 之前有几篇文章是关于太极图形编程语言的,虽然这个编程语言在圈里引发了不少的关注和点赞,不过还是有很多朋友不太了解,...
- 本章介绍如何使用方舟开发框架“一多”能力,开发出在多设备上正常显示的页面。方舟开发框架推荐开发者使用声明式开发范式...
- NDK(Native Development Kit)是OpenHarmony SDK提供的Native API、...