ts-universal-attributes-enable.md 1.2 KB
Newer Older
Z
zengyawen 已提交
1
# Enable/Disable
Z
zengyawen 已提交
2 3


Z
zengyawen 已提交
4 5 6 7 8
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.


## Required Permissions
Z
zengyawen 已提交
9 10 11

None

Z
zengyawen 已提交
12

Z
zengyawen 已提交
13 14 15 16 17 18 19 20 21 22 23
## Attributes


  | Name | Type | Default Value | Description | 
| -------- | -------- | -------- | -------- |
| enabled | boolean | true | The value **true** means that the component is available and can respond to operations such as clicking. The value **false** means that the component does not respond to operations such as clicking. | 


## Example

  
Z
zengyawen 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
```
@Entry
@Component
struct EnabledExample {
  build() {
    Flex({ justifyContent: FlexAlign.SpaceAround }) {
      // No response upon a click.
      Button('disable').enabled(false).backgroundColor(0x317aff).opacity(0.4)
      Button('enable').backgroundColor(0x317aff)
    }
    .width('100%')
    .padding({ top: 5 })
  }
}
```

Z
zengyawen 已提交
40
![en-us_image_0000001212218428](figures/en-us_image_0000001212218428.gif)