提交 237ee3f5 编写于 作者: L lihong

lihong67@huawei.com

Added restrictions on the use of status variables.
Signed-off-by: Nlihong <lihong67@huawei.com>
Change-Id: I6498fd51636a01804fbfb103d358f08109e7e030
上级 934b06ac
...@@ -55,4 +55,39 @@ OpenHarmony应用沙箱组件 ...@@ -55,4 +55,39 @@ OpenHarmony应用沙箱组件
![](figures/compile-change2-1.png) ![](figures/compile-change2-1.png)
![](figures/compile-change2-2.png) ![](figures/compile-change2-2.png)
\ No newline at end of file
**变更3**:状态变量多种数据类型声明使用限制。
状态变量比如@State、@Provide、 @Link和@Consume等,定义数据类型时,只能同时由简单数据类型或对象引用数据类型其中一种构成。
示例:
```ts
@Entry
@Component
struct Index {
//错误写法: @State message: string | Resource = 'Hello World'
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(`${ this.message }`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
```
**关键的接口/组件变更**
**适配指导**
当定义的状态变量类型中同时包含简单类型和对象引用数据类型时,需修改为只含有其中一种,如上述示例代码所示。
\ No newline at end of file
...@@ -172,6 +172,41 @@ FA模型下的公共模块变量共享之前是作为需求交付的,在中间 ...@@ -172,6 +172,41 @@ FA模型下的公共模块变量共享之前是作为需求交付的,在中间
### 状态变量多种数据类型声明使用限制。
状态变量比如@State、@Provide、 @Link和@Consume等,定义数据类型时,只能同时由简单数据类型或对象引用数据类型其中一种构成。
示例:
```ts
@Entry
@Component
struct Index {
//错误写法: @State message: string | Resource = 'Hello World'
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(`${ this.message }`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
```
**变更影响**
当定义的状态变量类型中同时包含简单类型和对象引用数据类型时,编译报错提示不支持。
**关键的接口/组件变更**
当定义的状态变量类型中同时包含简单类型和对象引用数据类型时,需修改为只含有其中一种,如上述示例代码所示。
## 全球化子系统 ## 全球化子系统
### 针对color.json中颜色值,增加合法性校验 ### 针对color.json中颜色值,增加合法性校验
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册