未验证 提交 0880bf9d 编写于 作者: O openharmony_ci 提交者: Gitee

!20177 add 组件成员装饰器规则

Merge pull request !20177 from Bo Jiang/master
# arkui子系统ChangeLog
### UI范式装饰器使用限制
#### 1.组件装饰器使用限制
组件装饰器@Component、@Entry、 @Preview和@CustomDialog只能作用于struct组件,不能用于装饰类class。
**示例:**
```
@Component
// ERROR:The '@Component' decorator can only be used with 'struct'.
class Index {
build() {
}
}
```
**变更影响**
如果组件装饰器@Component、@Entry、 @Preview和@CustomDialog 不是装饰struct组件,编译报错。
**关键的接口/组件变更**
不涉及。
**适配指导**
组件装饰器@Component、@Entry、 @Preview和@CustomDialog修饰struct组件。
#### 2.组件成员变量装饰器使用限制
组件成员变量装饰器@State、@Prop、@Link、@Provide、@Consume、@ObjectLink、@StorageLink、@StorageProp、@LocalStorageLink、@LocalStorageProp、@Watch、@BuilderParam只能装饰struct组件的成员变量。
**示例:**
```
@Component
class Index {
// ERROR: The '@State' decorator can only be used with 'struct'.
@State message: string = 'Hello world'
build() {
}
}
```
**变更影响**
如果上述提到的组件成员变量装饰器不是装饰struct组件的成员变量,编译报错。
**关键的接口/组件变更**
不涉及
**适配指导**
组件成员变量装饰器如果装饰了非struct组件成员变量,请将该变量作用在'struct'组件内。
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册