• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# restoreId
2
3The **restoreId** attribute identifies a component in distributed migration scenarios. It can be used to restore the component to a specific state on a remote device.
4
5>  **NOTE**
6>
7>  The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
8
9## restoreId
10
11restoreId(value: number)
12
13ID of the component used for device matching during distributed migration.
14
15**System capability**: SystemCapability.ArkUI.ArkUI.Full
16
17**Parameters**
18
19| Name| Type  | Mandatory| Description                                                        |
20| ------ | ------ | ---- | ------------------------------------------------------------ |
21| value  | number | Yes  | ID of the component used for device matching during distributed migration. This ID must be unique within an application.|
22
23## Components with Distributed Migration Support
24
25| Name     | Initial API Version| Description                                    |
26| --------- | ---- | ---------------------------------------- |
27| List      | 8    | The index of the list item displayed at the top of the list on the current device will be migrated to the remote device. After the migration, the list item that matches the index is displayed at the top of the list on the remote device.|
28| Grid      | 9    | The index of the grid item displayed at the top of the grid on the current device will be migrated to the remote device. After the migration, the grid item that matches the index is displayed at the top of the grid on the remote device. The position of the scrollbar cannot be migrated.|
29| Scroll    | 9    | The absolute distance with the top edge for scrolling will be migrated. The migration effect may be affected by the layout inconsistency resulting from differences in the display specifications between devices.|
30| WaterFlow | 11   | The index of the **\<FlowItem>** component (child) displayed at the top of the **\<WaterFlow>** component (parent) on the current device, along with the offset (in vp) of the child relative to the main axis of the parent, will be migrated to the remote device. After the migration, the **\<FlowItem>** component that matches the migrated index is displayed on the top of the **\<WaterFlow>** component on the remote device.|
31
32## Example
33
34```ts
35// xxx.ets
36@Entry
37@Component
38struct RestoreIdExample {
39  private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
40  build() {
41    Column() {
42      List({ space: 20 }) {
43        ForEach(this.arr, (item:number) => {
44          ListItem() {
45            Text('' + item)
46              .width('100%')
47              .height(100)
48              .fontSize(16)
49              .textAlign(TextAlign.Center)
50              .borderRadius(10)
51              .backgroundColor(Color.Pink)
52          }
53        }, (item:number) => (item.toString()))
54      }
55      .restoreId(1)
56    }
57  }
58}
59```
60