1#  arkui子系统ChangeLog
2
3### UI范式装饰器使用限制
4
5#### 1.组件装饰器使用限制
6
7组件装饰器@Component、@Entry、 @Preview和@CustomDialog只能作用于struct组件,不能用于装饰类class。
8
9**示例:**
10
11```
12@Component
13  // ERROR:The '@Component' decorator can only be used with 'struct'.
14class Index {
15  build() {
16  }
17}
18```
19
20**变更影响**
21
22如果组件装饰器@Component、@Entry、 @Preview和@CustomDialog 不是装饰struct组件,编译报错。
23
24**关键的接口/组件变更**
25
26不涉及。
27
28**适配指导**
29
30组件装饰器@Component、@Entry、 @Preview和@CustomDialog修饰struct组件。
31
32#### 2.组件成员变量装饰器使用限制
33
34组件成员变量装饰器@State、@Prop、@Link、@Provide、@Consume、@ObjectLink、@StorageLink、@StorageProp、@LocalStorageLink、@LocalStorageProp、@Watch、@BuilderParam只能装饰struct组件的成员变量。
35
36**示例:**
37
38```
39@Component
40class Index {
41  // ERROR: The '@State' decorator can only be used with 'struct'.
42  @State message: string = 'Hello world'
43
44  build() {
45
46  }
47}
48```
49
50**变更影响**
51
52如果上述提到的组件成员变量装饰器不是装饰struct组件的成员变量,编译报错。
53
54**关键的接口/组件变更**
55
56不涉及
57
58**适配指导**
59
60组件成员变量装饰器如果装饰了非struct组件成员变量,请将该变量作用在'struct'组件内。