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


E
esterzhou 已提交
4
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
Z
zengyawen 已提交
5 6 7 8
> 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
## Attributes


E
esterzhou 已提交
16
  | Name | Type | Default Value | Description | 
Z
zengyawen 已提交
17
| -------- | -------- | -------- | -------- |
E
esterzhou 已提交
18
| 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. | 
Z
zengyawen 已提交
19 20 21 22 23


## 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)