样式多态

71 阅读1分钟

stateStyles()  可以根据组件内部状态不同快速设置不同的样式

focused 聚焦态

normal 正常态

pressed 按压态

disabled 不可用态

设置获焦
.focusable(this.focus) //获取状态
禁用状态
.enabled(this.isable)
//设置多态样式
.stateStyles({
    normal:{
        .backgroundColor('#ccc')
    }
    pressed:{
        .backgroundColor('#ccc')
    }
    focused:{
        .backgroundColor('#333')
    }
    .disabled:{
        .background('#000')
    }
})

默认页面的第一个元素为聚焦态。