Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
54c73c25
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
54c73c25
编写于
8月 31, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 31, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23567 Rectify the arkts syntax of qs
Merge pull request !23567 from 189******51/master
上级
0bc86089
4a762b38
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
151 addition
and
129 deletion
+151
-129
zh-cn/application-dev/quick-start/arkts-animatable-extend.md
zh-cn/application-dev/quick-start/arkts-animatable-extend.md
+6
-6
zh-cn/application-dev/quick-start/arkts-appstorage.md
zh-cn/application-dev/quick-start/arkts-appstorage.md
+43
-23
zh-cn/application-dev/quick-start/arkts-environment.md
zh-cn/application-dev/quick-start/arkts-environment.md
+1
-1
zh-cn/application-dev/quick-start/arkts-link.md
zh-cn/application-dev/quick-start/arkts-link.md
+2
-2
zh-cn/application-dev/quick-start/arkts-localstorage.md
zh-cn/application-dev/quick-start/arkts-localstorage.md
+61
-58
zh-cn/application-dev/quick-start/arkts-observed-and-objectlink.md
...lication-dev/quick-start/arkts-observed-and-objectlink.md
+9
-9
zh-cn/application-dev/quick-start/arkts-persiststorage.md
zh-cn/application-dev/quick-start/arkts-persiststorage.md
+1
-1
zh-cn/application-dev/quick-start/arkts-prop.md
zh-cn/application-dev/quick-start/arkts-prop.md
+28
-29
未找到文件。
zh-cn/application-dev/quick-start/arkts-animatable-extend.md
浏览文件 @
54c73c25
...
...
@@ -101,7 +101,7 @@ class PointVector extends Array<Point> implements AnimatableArithmetic<PointVect
let
result
=
new
PointVector
([])
const
len
=
Math
.
min
(
this
.
length
,
rhs
.
length
)
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
result
.
push
(
this
[
i
].
plus
(
rhs
[
i
]))
result
.
push
(
(
this
as
Array
<
Point
>
)[
i
].
plus
((
rhs
as
Array
<
Point
>
)
[
i
]))
}
return
result
}
...
...
@@ -109,14 +109,14 @@ class PointVector extends Array<Point> implements AnimatableArithmetic<PointVect
let
result
=
new
PointVector
([])
const
len
=
Math
.
min
(
this
.
length
,
rhs
.
length
)
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
result
.
push
(
this
[
i
].
subtract
(
rhs
[
i
]))
result
.
push
(
(
this
as
Array
<
Point
>
)[
i
].
subtract
((
rhs
as
Array
<
Point
>
)
[
i
]))
}
return
result
}
multiply
(
scale
:
number
):
PointVector
{
let
result
=
new
PointVector
([])
for
(
let
i
=
0
;
i
<
this
.
length
;
i
++
)
{
result
.
push
(
this
[
i
].
multiply
(
scale
))
result
.
push
(
(
this
as
Array
<
Point
>
)
[
i
].
multiply
(
scale
))
}
return
result
}
...
...
@@ -125,14 +125,14 @@ class PointVector extends Array<Point> implements AnimatableArithmetic<PointVect
return
false
}
for
(
let
i
=
0
;
i
<
this
.
length
;
i
++
)
{
if
(
!
this
[
i
].
equals
(
rhs
[
i
]))
{
if
(
!
(
this
as
Array
<
Point
>
)[
i
].
equals
((
rhs
as
Array
<
Point
>
)
[
i
]))
{
return
false
}
}
return
true
}
get
():
Array
<
[
x
:
number
,
y
:
number
]
>
{
let
result
=
[]
get
():
Array
<
Object
[
]
>
{
let
result
:
Array
<
Object
[]
>
=
[]
this
.
forEach
(
p
=>
result
.
push
([
p
.
x
,
p
.
y
]))
return
result
}
...
...
zh-cn/application-dev/quick-start/arkts-appstorage.md
浏览文件 @
54c73c25
...
...
@@ -144,21 +144,22 @@ AppStorage是单例,它的所有API都是静态的,使用方法类似于中L
```
ts
AppStorage
.
SetOrCreate
(
'
PropA
'
,
47
);
let
storage
:
LocalStorage
=
new
LocalStorage
({
'
PropA
'
:
17
});
let
propA
:
number
=
AppStorage
.
Get
(
'
PropA
'
)
// propA in AppStorage == 47, propA in LocalStorage == 17
var
link1
:
SubscribedAbstractProperty
<
number
>
=
AppStorage
.
Link
(
'
PropA
'
);
// link1.get() == 47
var
link2
:
SubscribedAbstractProperty
<
number
>
=
AppStorage
.
Link
(
'
PropA
'
);
// link2.get() == 47
var
prop
:
SubscribedAbstractProperty
<
number
>
=
AppStorage
.
Prop
(
'
PropA
'
);
// prop.get() = 47
let
storage
:
LocalStorage
=
new
LocalStorage
();
storage
[
'
PropA
'
]
=
17
;
let
propA
:
number
|
undefined
=
AppStorage
.
Get
(
'
PropA
'
)
// propA in AppStorage == 47, propA in LocalStorage == 17
let
link1
:
SubscribedAbstractProperty
<
number
>
=
AppStorage
.
Link
(
'
PropA
'
);
// link1.get() == 47
let
link2
:
SubscribedAbstractProperty
<
number
>
=
AppStorage
.
Link
(
'
PropA
'
);
// link2.get() == 47
let
prop
:
SubscribedAbstractProperty
<
number
>
=
AppStorage
.
Prop
(
'
PropA
'
);
// prop.get() = 47
link1
.
set
(
48
);
// two-way sync: link1.get() == link2.get() == prop.get() == 48
prop
.
set
(
1
);
// one-way sync: prop.get()=1; but link1.get() == link2.get() == 48
link1
.
set
(
49
);
// two-way sync: link1.get() == link2.get() == prop.get() == 49
storage
.
get
(
'
PropA
'
)
// == 17
storage
.
get
<
number
>
(
'
PropA
'
)
// == 17
storage
.
set
(
'
PropA
'
,
101
);
storage
.
get
(
'
PropA
'
)
// == 101
storage
.
get
<
number
>
(
'
PropA
'
)
// == 101
AppStorage
.
Get
(
'
PropA
'
)
// == 49
AppStorage
.
Get
<
number
>
(
'
PropA
'
)
// == 49
link1
.
get
()
// == 49
link2
.
get
()
// == 49
prop
.
get
()
// == 49
...
...
@@ -172,7 +173,8 @@ prop.get() // == 49
```
ts
AppStorage
.
SetOrCreate
(
'
PropA
'
,
47
);
let
storage
=
new
LocalStorage
({
'
PropA
'
:
48
});
let
storage
=
new
LocalStorage
();
storage
[
'
PropA
'
]
=
48
;
@
Entry
(
storage
)
@
Component
...
...
@@ -242,8 +244,13 @@ struct Gallery2 {
export
struct
TapImage
{
@
StorageLink
(
'
tapIndex
'
)
@
Watch
(
'
onTapIndexChange
'
)
tapIndex
:
number
=
-
1
;
@
State
tapColor
:
Color
=
Color
.
Black
;
private
index
:
number
;
private
uri
:
Resource
;
private
index
:
number
=
0
;
private
uri
:
Resource
=
{
id
:
0
,
type
:
0
,
moduleName
:
""
,
bundleName
:
""
};
// 判断是否被选中
onTapIndexChange
()
{
...
...
@@ -313,9 +320,9 @@ struct Gallery2 {
if
(
this
.
preIndex
===
item
.
id
)
{
return
}
var
i
nnerEvent
=
{
eventId
:
item
.
id
}
let
innerEvent
:
emitter
.
I
nnerEvent
=
{
eventId
:
item
.
id
}
// 选中态:黑变红
var
e
ventData
=
{
let
eventData
:
emitter
.
E
ventData
=
{
data
:
{
"
colorTag
"
:
1
}
...
...
@@ -324,9 +331,9 @@ struct Gallery2 {
if
(
this
.
preIndex
!=
-
1
)
{
console
.
info
(
`preIndex:
${
this
.
preIndex
}
, index:
${
item
.
id
}
, black`
)
var
i
nnerEvent
=
{
eventId
:
this
.
preIndex
}
let
innerEvent
:
emitter
.
I
nnerEvent
=
{
eventId
:
this
.
preIndex
}
// 取消选中态:红变黑
var
e
ventData
=
{
let
eventData
:
emitter
.
E
ventData
=
{
data
:
{
"
colorTag
"
:
0
}
...
...
@@ -335,7 +342,6 @@ struct Gallery2 {
}
this
.
preIndex
=
item
.
id
})
},
(
item
:
ViewData
)
=>
JSON
.
stringify
(
item
))
}.
columnsTemplate
(
'
1fr 1fr
'
)
}
...
...
@@ -346,17 +352,26 @@ struct Gallery2 {
@
Component
export
struct
TapImage
{
@
State
tapColor
:
Color
=
Color
.
Black
;
private
index
:
number
;
private
uri
:
Resource
;
private
index
:
number
=
0
;
private
uri
:
Resource
=
{
id
:
0
,
type
:
0
,
moduleName
:
""
,
bundleName
:
""
};
onTapIndexChange
(
colorTag
:
emitter
.
EventData
)
{
this
.
tapColor
=
colorTag
.
data
.
colorTag
?
Color
.
Red
:
Color
.
Black
if
(
colorTag
.
data
!=
null
)
{
this
.
tapColor
=
colorTag
.
data
.
colorTag
?
Color
.
Red
:
Color
.
Black
}
}
aboutToAppear
()
{
//定义事件ID
var
innerEvent
=
{
eventId
:
this
.
index
}
emitter
.
on
(
innerEvent
,
this
.
onTapIndexChange
.
bind
(
this
))
let
innerEvent
:
emitter
.
InnerEvent
=
{
eventId
:
this
.
index
}
emitter
.
on
(
innerEvent
,
data
=>
{
this
.
onTapIndexChange
(
data
)
})
}
build
()
{
...
...
@@ -414,8 +429,13 @@ struct Gallery2 {
export struct TapImage {
@StorageLink('tapIndex') tapIndex: number = -1;
@State tapColor: Color = Color.Black;
private index: number;
private uri: Resource;
private index: number = 0;
private uri: Resource = {
id: 0,
type: 0,
moduleName: "",
bundleName: ""
};
build() {
Column() {
...
...
zh-cn/application-dev/quick-start/arkts-environment.md
浏览文件 @
54c73c25
...
...
@@ -35,7 +35,7 @@ Environment是ArkUI框架在应用程序启动时创建的单例对象。它为A
```
ts
// 将设备languageCode存入AppStorage中
Environment
.
EnvProp
(
'
languageCode
'
,
'
en
'
);
let
enable
=
AppStorage
.
Get
(
'
languageCode
'
);
let
enable
:
undefined
=
AppStorage
.
Get
<
undefined
>
(
'
languageCode
'
);
@
Entry
@
Component
...
...
zh-cn/application-dev/quick-start/arkts-link.md
浏览文件 @
54c73c25
...
...
@@ -227,10 +227,10 @@ struct Parent {
Column
()
{
Child
({
items
:
$arr
})
ForEach
(
this
.
arr
,
item
=>
{
(
item
:
void
)
=>
{
Text
(
`
${
item
}
`
)
},
item
=>
item
.
toString
()
(
item
:
ForEachInterface
)
=>
item
.
toString
()
)
}
}
...
...
zh-cn/application-dev/quick-start/arkts-localstorage.md
浏览文件 @
54c73c25
...
...
@@ -191,36 +191,37 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
-
\@
LocalStorageLink绑定LocalStorage对给定的属性,建立双向数据同步。
```
ts
// 创建新实例并使用给定对象初始化
let
storage
=
new
LocalStorage
({
'
PropA
'
:
47
}
);
@
Component
struct
Child
{
// @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定
@
LocalStorageLink
(
'
PropA
'
)
storLink2
:
number
=
1
;
build
()
{
Button
(
`Child from LocalStorage
${
this
.
storLink2
}
`
)
// 更改将同步至LocalStorage中的'ProA'以及Parent.storLink1
.
onClick
(()
=>
this
.
storLink2
+=
1
)
}
// 创建新实例并使用给定对象初始化
let
storage
=
new
LocalStorage
(
);
storage
[
'
PropA
'
]
=
47
;
@
Component
struct
Child
{
// @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定
@
LocalStorageLink
(
'
PropA
'
)
storLink2
:
number
=
1
;
build
()
{
Button
(
`Child from LocalStorage
${
this
.
storLink2
}
`
)
// 更改将同步至LocalStorage中的'ProA'以及Parent.storLink1
.
onClick
(()
=>
this
.
storLink2
+=
1
)
}
// 使LocalStorage可从@Component组件访问
@
Entry
(
storage
)
@
Component
struct
CompA
{
// @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定
@
LocalStorageLink
(
'
PropA
'
)
storLink1
:
number
=
1
;
build
()
{
Column
({
space
:
15
}
)
{
Button
(
`Parent from LocalStorage
${
this
.
storLink1
}
`
)
// initial value from LocalStorage will be 47, because 'PropA' initialized already
.
onClick
(()
=>
this
.
storLink1
+=
1
)
// @Component子组件自动获得对CompA LocalStorage实例的访问权限。
Child
()
}
}
// 使LocalStorage可从@Component组件访问
@
Entry
(
storage
)
@
Component
struct
CompA
{
// @LocalStorageLink变量装饰器与LocalStorage中的'ProA'属性建立双向绑定
@
LocalStorageLink
(
'
PropA
'
)
storLink1
:
number
=
1
;
build
(
)
{
Column
({
space
:
15
})
{
Button
(
`Parent from LocalStorage
${
this
.
storLink1
}
`
)
// initial value from LocalStorage will be 47, because 'PropA' initialized already
.
onClick
(()
=>
this
.
storLink1
+=
1
)
// @Component子组件自动获得对CompA LocalStorage实例的访问权限。
Child
()
}
}
}
```
...
...
@@ -233,37 +234,39 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
-
Child组件中,Text绑定的storProp2 依旧显示47。
```
ts
// 创建新实例并使用给定对象初始化
let
storage
=
new
LocalStorage
({
'
PropA
'
:
47
});
// 使LocalStorage可从@Component组件访问
@
Entry
(
storage
)
@
Component
struct
CompA
{
// @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定
@
LocalStorageProp
(
'
PropA
'
)
storProp1
:
number
=
1
;
build
()
{
Column
({
space
:
15
})
{
// 点击后从47开始加1,只改变当前组件显示的storProp1,不会同步到LocalStorage中
Button
(
`Parent from LocalStorage
${
this
.
storProp1
}
`
)
.
onClick
(()
=>
this
.
storProp1
+=
1
)
Child
()
}
// 创建新实例并使用给定对象初始化
let
storage
=
new
LocalStorage
();
storage
[
'
PropA
'
]
=
47
;
// 使LocalStorage可从@Component组件访问
@
Entry
(
storage
)
@
Component
struct
CompA
{
// @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定
@
LocalStorageProp
(
'
PropA
'
)
storProp1
:
number
=
1
;
build
()
{
Column
({
space
:
15
})
{
// 点击后从47开始加1,只改变当前组件显示的storProp1,不会同步到LocalStorage中
Button
(
`Parent from LocalStorage
${
this
.
storProp1
}
`
)
.
onClick
(()
=>
this
.
storProp1
+=
1
)
Child
()
}
}
}
@
Component
struct
Child
{
// @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定
@
LocalStorageProp
(
'
PropA
'
)
storProp2
:
number
=
2
;
@
Component
struct
Child
{
// @LocalStorageProp变量装饰器与LocalStorage中的'ProA'属性建立单向绑定
@
LocalStorageProp
(
'
PropA
'
)
storProp2
:
number
=
2
;
build
()
{
Column
({
space
:
15
})
{
// 当CompA改变时,当前storProp2不会改变,显示47
Text
(
`Parent from LocalStorage
${
this
.
storProp2
}
`
)
}
build
()
{
Column
({
space
:
15
})
{
// 当CompA改变时,当前storProp2不会改变,显示47
Text
(
`Parent from LocalStorage
${
this
.
storProp2
}
`
)
}
}
}
```
...
...
@@ -274,9 +277,10 @@ link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49
```
ts
// 构造LocalStorage实例
let
storage
=
new
LocalStorage
({
'
PropA
'
:
47
});
let
storage
=
new
LocalStorage
();
storage
[
'
PropA
'
]
=
47
;
// 调用link9+接口构造'PropA'的双向同步数据,linkToPropA 是全局变量
let
linkToPropA
=
storage
.
link
(
'
PropA
'
);
let
linkToPropA
=
storage
.
link
<
number
>
(
'
PropA
'
);
@
Entry
(
storage
)
@
Component
...
...
@@ -288,7 +292,7 @@ struct CompA {
build
()
{
Column
()
{
Text
(
`incr @LocalStorageLink variable`
)
// 点击“incr @LocalStorageLink variable”,this.storLink加1,改变同步回storage,全局变量linkToPropA也会同步改变
// 点击“incr @LocalStorageLink variable”,this.storLink加1,改变同步回storage,全局变量linkToPropA也会同步改变
.
onClick
(()
=>
this
.
storLink
+=
1
)
...
...
@@ -388,11 +392,10 @@ import UIAbility from '@ohos.app.ability.UIAbility';
import
window
from
'
@ohos.window
'
;
export
default
class
EntryAbility
extends
UIAbility
{
storage
:
LocalStorage
=
new
LocalStorage
({
'
PropA
'
:
47
});
storage
:
LocalStorage
=
new
LocalStorage
();
onWindowStageCreate
(
windowStage
:
window
.
WindowStage
)
{
this
.
storage
[
'
PropA
'
]
=
47
;
windowStage
.
loadContent
(
'
pages/Index
'
,
this
.
storage
);
}
}
...
...
zh-cn/application-dev/quick-start/arkts-observed-and-objectlink.md
浏览文件 @
54c73c25
...
...
@@ -126,7 +126,7 @@ this.b.a.c = 5
```
ts
@
Observed
class
DateClass
extends
Date
{
constructor
(
args
:
any
)
{
constructor
(
args
:
number
|
string
)
{
super
(
args
)
}
}
...
...
@@ -343,10 +343,10 @@ struct ViewB {
build
()
{
Column
()
{
ForEach
(
this
.
arrA
,
(
item
)
=>
{
(
item
:
ClassA
)
=>
{
ViewA
({
label
:
`#
${
item
.
id
}
`
,
a
:
item
})
},
(
item
)
=>
item
.
id
.
toString
()
(
item
:
ClassA
)
=>
item
.
id
.
toString
()
)
// 使用@State装饰的数组的数组项初始化@ObjectLink,其中数组项是被@Observed装饰的ClassA的实例
ViewA
({
label
:
`ViewA this.arrA[first]`
,
a
:
this
.
arrA
[
0
]
})
...
...
@@ -419,11 +419,11 @@ struct ItemPage {
.
width
(
100
).
height
(
100
)
ForEach
(
this
.
itemArr
,
item
=>
{
(
item
:
string
|
Resource
)
=>
{
Text
(
item
)
.
width
(
100
).
height
(
100
)
},
item
=>
item
(
item
:
string
)
=>
item
)
}
}
...
...
@@ -439,14 +439,14 @@ struct IndexPage {
ItemPage
({
itemArr
:
this
.
arr
[
0
]
})
ItemPage
({
itemArr
:
this
.
arr
[
1
]
})
ItemPage
({
itemArr
:
this
.
arr
[
2
]
})
Divider
()
ForEach
(
this
.
arr
,
itemArr
=>
{
(
itemArr
:
StringArray
)
=>
{
ItemPage
({
itemArr
:
itemArr
})
},
itemArr
=>
itemArr
[
0
]
(
itemArr
:
string
)
=>
itemArr
[
0
]
)
Divider
()
...
...
@@ -454,7 +454,7 @@ struct IndexPage {
Button
(
'
update
'
)
.
onClick
(()
=>
{
console
.
error
(
'
Update all items in arr
'
);
if
(
this
.
arr
[
0
]
[
0
]
!==
undefined
)
{
if
(
(
this
.
arr
[
0
]
as
Array
<
String
>
)
[
0
]
!==
undefined
)
{
// 正常情况下需要有一个真实的ID来与ForEach一起使用,但此处没有
// 因此需要确保推送的字符串是唯一的。
this
.
arr
[
0
].
push
(
`
${
this
.
arr
[
0
].
slice
(
-
1
).
pop
()}${
this
.
arr
[
0
].
slice
(
-
1
).
pop
()}
`
);
...
...
zh-cn/application-dev/quick-start/arkts-persiststorage.md
浏览文件 @
54c73c25
...
...
@@ -40,7 +40,7 @@ PersistentStorage和UIContext相关联,需要在[UIContext](../reference/apis/
2.
在AppStorage获取对应属性:
```
ts
AppStorage
.
Get
(
'
aProp
'
);
// returns 47
AppStorage
.
Get
<
number
>
(
'
aProp
'
);
// returns 47
```
或在组件内部定义:
...
...
zh-cn/application-dev/quick-start/arkts-prop.md
浏览文件 @
54c73c25
...
...
@@ -118,7 +118,7 @@ this.title.push('3')
```
ts
@
Component
struct
DateComponent
{
@
Prop
selectedDate
:
Date
;
@
Prop
selectedDate
:
Date
=
new
Date
(
''
)
;
build
()
{
Column
()
{
...
...
@@ -198,7 +198,7 @@ ParentComponent的状态变量countDownStartValue的变化将重置CountDownComp
```
ts
@
Component
struct
CountDownComponent
{
@
Prop
count
:
number
;
@
Prop
count
:
number
=
0
;
costOfOneAttempt
:
number
=
1
;
build
()
{
...
...
@@ -370,7 +370,7 @@ class Book {
@
Component
struct
ReaderComp
{
@
Prop
book
:
Book
;
@
Prop
book
:
Book
=
new
Book
(
""
,
0
)
;
build
()
{
Row
()
{
...
...
@@ -419,7 +419,7 @@ class Book {
@
Component
struct
ReaderComp
{
@
Prop
book
:
Book
;
@
Prop
book
:
Book
=
new
Book
(
""
,
1
)
;
build
()
{
Row
()
{
...
...
@@ -442,10 +442,10 @@ struct Library {
ReaderComp
({
book
:
this
.
allBooks
[
2
]
})
Divider
()
Text
(
'
Books on loaan to a reader
'
)
ForEach
(
this
.
allBooks
,
book
=>
{
ForEach
(
this
.
allBooks
,
(
book
:
Book
)
=>
{
ReaderComp
({
book
:
book
})
},
book
=>
book
.
id
)
(
book
:
Book
)
=>
book
.
id
.
toString
()
)
Button
(
'
Add new
'
)
.
onClick
(()
=>
{
this
.
allBooks
.
push
(
new
Book
(
"
The C++ Standard Library
"
,
512
));
...
...
@@ -497,7 +497,7 @@ class Book {
```
ts
@
Component
struct
MyComponent
{
@
Prop
customCounter
:
number
;
@
Prop
customCounter
:
number
=
0
;
@
Prop
customCounter2
:
number
=
5
;
build
()
{
...
...
@@ -579,7 +579,6 @@ class ClassB {
以下组件层次结构呈现的是@Prop嵌套场景的数据结构。
```
ts
@
Entry
@
Component
struct
Parent
{
...
...
@@ -588,10 +587,10 @@ struct Parent {
build
()
{
Column
()
{
Button
(
'
change
'
)
.
onClick
(()
=>
{
this
.
votes
.
name
=
"
aaaaa
"
this
.
votes
.
a
.
title
=
"
wwwww
"
})
.
onClick
(()
=>
{
this
.
votes
.
name
=
"
aaaaa
"
this
.
votes
.
a
.
title
=
"
wwwww
"
})
Child
({
vote
:
this
.
votes
})
}
...
...
@@ -600,33 +599,33 @@ struct Parent {
@
Component
struct
Child
{
@
Prop
vote
:
ClassB
@
Prop
vote
:
ClassB
=
new
ClassB
(
''
,
new
ClassA
(
''
));
build
()
{
Column
()
{
Column
()
{
Text
(
this
.
vote
.
name
).
fontSize
(
36
).
fontColor
(
Color
.
Red
).
margin
(
50
)
.
onClick
(()
=>
{
this
.
vote
.
name
=
'
Bye
'
})
Text
(
this
.
vote
.
a
.
title
).
fontSize
(
36
).
fontColor
(
Color
.
Blue
)
.
onClick
(()
=>
{
this
.
vote
.
a
.
title
=
"
openHarmony
"
})
Child1
({
vote1
:
this
.
vote
.
a
})
Text
(
this
.
vote
.
name
).
fontSize
(
36
).
fontColor
(
Color
.
Red
).
margin
(
50
)
.
onClick
(()
=>
{
this
.
vote
.
name
=
'
Bye
'
})
Text
(
this
.
vote
.
a
.
title
).
fontSize
(
36
).
fontColor
(
Color
.
Blue
)
.
onClick
(()
=>
{
this
.
vote
.
a
.
title
=
"
openHarmony
"
})
Child1
({
vote1
:
this
.
vote
.
a
})
}
}
}
}
@
Component
struct
Child1
{
@
Prop
vote1
:
ClassA
@
Prop
vote1
:
ClassA
=
new
ClassA
(
''
);
build
()
{
Column
()
{
Text
(
this
.
vote1
.
title
).
fontSize
(
36
).
fontColor
(
Color
.
Red
).
margin
(
50
)
.
onClick
(()
=>
{
this
.
vote1
.
title
=
'
Bye Bye
'
})
Text
(
this
.
vote1
.
title
).
fontSize
(
36
).
fontColor
(
Color
.
Red
).
margin
(
50
)
.
onClick
(()
=>
{
this
.
vote1
.
title
=
'
Bye Bye
'
})
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录