ts-universal-attributes-enable.md 2.6 KB
Newer Older
Z
zengyawen 已提交
1 2 3 4 5 6 7 8 9 10
# Enable/Disable<a name="EN-US_TOPIC_0000001192595162"></a>

>![](../../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<a name="section781125411508"></a>

None

## Attributes<a name="section6820191711316"></a>
Z
zengyawen 已提交
11 12 13 14

<a name="table3897mcpsimp"></a>
<table><thead align="left"><tr id="row3904mcpsimp"><th class="cellrowborder" valign="top" width="12.24%" id="mcps1.1.5.1.1"><p id="p3906mcpsimp"><a name="p3906mcpsimp"></a><a name="p3906mcpsimp"></a>Name</p>
</th>
Z
zengyawen 已提交
15
<th class="cellrowborder" valign="top" width="12.08%" id="mcps1.1.5.1.2"><p id="p3908mcpsimp"><a name="p3908mcpsimp"></a><a name="p3908mcpsimp"></a>Type</p>
Z
zengyawen 已提交
16
</th>
Z
zengyawen 已提交
17
<th class="cellrowborder" valign="top" width="10.870000000000001%" id="mcps1.1.5.1.3"><p id="p3910mcpsimp"><a name="p3910mcpsimp"></a><a name="p3910mcpsimp"></a>Default Value</p>
Z
zengyawen 已提交
18 19 20 21 22 23 24
</th>
<th class="cellrowborder" valign="top" width="64.81%" id="mcps1.1.5.1.4"><p id="p3912mcpsimp"><a name="p3912mcpsimp"></a><a name="p3912mcpsimp"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row3913mcpsimp"><td class="cellrowborder" valign="top" width="12.24%" headers="mcps1.1.5.1.1 "><p id="p3915mcpsimp"><a name="p3915mcpsimp"></a><a name="p3915mcpsimp"></a>enabled</p>
</td>
Z
zengyawen 已提交
25
<td class="cellrowborder" valign="top" width="12.08%" headers="mcps1.1.5.1.2 "><p id="p3917mcpsimp"><a name="p3917mcpsimp"></a><a name="p3917mcpsimp"></a>boolean</p>
Z
zengyawen 已提交
26
</td>
Z
zengyawen 已提交
27
<td class="cellrowborder" valign="top" width="10.870000000000001%" headers="mcps1.1.5.1.3 "><p id="p3919mcpsimp"><a name="p3919mcpsimp"></a><a name="p3919mcpsimp"></a>true</p>
Z
zengyawen 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
</td>
<td class="cellrowborder" valign="top" width="64.81%" headers="mcps1.1.5.1.4 "><p id="p3921mcpsimp"><a name="p3921mcpsimp"></a><a name="p3921mcpsimp"></a>The value <strong id="b14522251174915"><a name="b14522251174915"></a><a name="b14522251174915"></a>true</strong> means that the component is available and can respond to operations such as clicking. The value <strong id="b9788591501"><a name="b9788591501"></a><a name="b9788591501"></a>false</strong> means that the component does not respond to operations such as clicking.</p>
</td>
</tr>
</tbody>
</table>

## Example<a name="section4278134412416"></a>

```
@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 })
  }
}
```

![](figures/enabled.gif)