Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
af1c47ed
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
350
Star
2
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
af1c47ed
编写于
9月 19, 2024
作者:
F
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增 响应式数组展开语法 自动化测试 issues=7897
上级
1711b29d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
10 deletion
+38
-10
pages/reactivity/core/reactive/reactive.test.js
pages/reactivity/core/reactive/reactive.test.js
+13
-2
pages/reactivity/core/reactive/reactive.uvue
pages/reactivity/core/reactive/reactive.uvue
+25
-8
未找到文件。
pages/reactivity/core/reactive/reactive.test.js
浏览文件 @
af1c47ed
...
...
@@ -17,7 +17,10 @@ describe('reactive', () => {
expect
(
await
objNum
.
text
()).
toBe
(
'
0
'
)
const
objArr
=
await
page
.
$
(
'
#obj-arr
'
)
expect
(
await
objArr
.
text
()).
toBe
(
'
["a","b","c"]
'
)
expect
(
await
objArr
.
text
()).
toBe
(
'
["a","b","c"]
'
)
const
arr1
=
await
page
.
$
(
'
#arr1
'
)
expect
(
await
arr1
.
text
()).
toBe
(
'
[]
'
)
const
updateCountBtn
=
await
page
.
$
(
'
#update-count-btn
'
)
await
updateCountBtn
.
tap
()
...
...
@@ -41,6 +44,14 @@ describe('reactive', () => {
const
updateObj_A_B_C_Btn
=
await
page
.
$
(
'
#update-obj1-a-b-c-btn
'
)
await
updateObj_A_B_C_Btn
.
tap
()
expect
(
await
count1
.
text
()).
toBe
(
'
2
'
)
expect
(
await
count1
.
text
()).
toBe
(
'
2
'
)
const
updateArr1Btn
=
await
page
.
$
(
'
#update-arr1-btn
'
)
await
updateArr1Btn
.
tap
()
expect
(
await
arr1
.
text
()).
toBe
(
'
[1,2,3]
'
)
const
updateArr1ReactiveBtn
=
await
page
.
$
(
'
#update-arr1-reactive-btn
'
)
await
updateArr1ReactiveBtn
.
tap
()
expect
(
await
arr1
.
text
()).
toBe
(
'
[4,5,6]
'
)
})
})
\ No newline at end of file
pages/reactivity/core/reactive/reactive.uvue
浏览文件 @
af1c47ed
...
...
@@ -15,20 +15,26 @@
<view class="flex justify-between flex-row mb-10">
<text>obj.arr:</text>
<text id="obj-arr">{{ JSON.stringify(obj['arr']) }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>count1:</text>
<text id="count1">{{ count1 }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>obj1.a.b.c:</text>
<text id="obj1-a-b-c">{{ obj1.getString('a.b.c') }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>count1:</text>
<text id="count1">{{ count1 }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>obj1.a.b.c:</text>
<text id="obj1-a-b-c">{{ obj1.getString('a.b.c') }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>arr1(spread):</text>
<text id="arr1">{{ arr1 }}</text>
</view>
<button class='mb-10' id="update-count-btn" @click="updateCount">update count</button>
<button class='mb-10' id="update-obj-str-btn" @click="updateObjStr">update obj.str</button>
<button class='mb-10' id="update-obj-num-btn" @click="updateObjNum">update obj.num</button>
<button class='mb-10' id="update-obj-arr-btn" @click="updateObjArr">update obj.arr</button>
<button class='mb-10' id="update-obj1-a-b-c-btn" @click="updateObj1_A_B_C">update obj1.a.b.c</button>
<button class='mb-10' id="update-arr1-btn" @click="updateArr1(false)">update arr1 without reactive</button>
<button class='mb-10' id="update-arr1-reactive-btn" @click="updateArr1(true)">update arr1 with reactive</button>
</view>
</template>
...
...
@@ -71,4 +77,15 @@
function updateObj1_A_B_C() {
((obj1["a"] as UTSJSONObject)["b"] as UTSJSONObject)["c"] = "c1-" + Date.now()
}
const arr1 = ref<number[]>([])
function test(...args : number[]) {
arr1.value = args
}
function updateArr1(isReactive : boolean) {
if (isReactive) {
test(...reactive([4, 5, 6]))
} else {
test(...[1, 2, 3])
}
}
</script>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录