赞
踩
Button('点我')
- Button() {
- Image($r('app.mdedia.xxx'))
- .width(120)
- .margin(10)
- }
其中,文本类型Button组件可以通过设置type属性来改变按钮的 形态,例如:圆形,圆角,直角(Normal)
按钮最重要的功能就是点击事件,可以通过onclick来添加点击事件
- Button('点我')
- .onClick(() => {
- console.log('点击了按钮')
- })
3、设置按钮不同状态的效果
可以通过属性stateStyles来控制按钮在不同状态下的效果
- Button(this.buttonState)
- .width(300)
- .height(50)
- .margin({top:100})
- .stateStyles({
- normal:{
- .backgroundColor(Color.Pink)
- },
- pressed:{
- .backgroundColor(Color.Blue)
- },
- disabled:{
- .backgroundColor(Color.Gray)
- }
-
- })
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。