Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
3a44faca
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
355
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看板
提交
3a44faca
编写于
1月 23, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 调整示例及测试,兼容 web 端
上级
1e272ee8
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
34 addition
and
26 deletion
+34
-26
pages/composition-api/basic/define-expose/define-expose.test.js
...composition-api/basic/define-expose/define-expose.test.js
+1
-1
pages/composition-api/basic/define-expose/define-expose.uvue
pages/composition-api/basic/define-expose/define-expose.uvue
+1
-1
pages/composition-api/basic/use-slots/Foo.uvue
pages/composition-api/basic/use-slots/Foo.uvue
+1
-1
pages/composition-api/basic/use-slots/use-slots.test.js
pages/composition-api/basic/use-slots/use-slots.test.js
+2
-2
pages/composition-api/dependency-injection/provide/inject.uvue
.../composition-api/dependency-injection/provide/inject.uvue
+7
-4
pages/composition-api/dependency-injection/provide/provide-inject.test.js
...n-api/dependency-injection/provide/provide-inject.test.js
+8
-6
pages/composition-api/reactivity/custom-ref/custom-ref.test.js
.../composition-api/reactivity/custom-ref/custom-ref.test.js
+8
-5
pages/composition-api/reactivity/custom-ref/custom-ref.uvue
pages/composition-api/reactivity/custom-ref/custom-ref.uvue
+2
-2
pages/composition-api/reactivity/reactive/reactive.test.js
pages/composition-api/reactivity/reactive/reactive.test.js
+3
-3
pages/composition-api/reactivity/reactive/reactive.uvue
pages/composition-api/reactivity/reactive/reactive.uvue
+1
-1
未找到文件。
pages/composition-api/basic/define-expose/define-expose.test.js
浏览文件 @
3a44faca
...
...
@@ -12,7 +12,7 @@ describe('defineExpose', () => {
const
fooNum
=
await
page
.
$
(
'
#foo-num
'
)
expect
(
await
fooNum
.
text
()).
toBe
(
'
num from component Foo: 0
'
)
const
incrementBtn
=
await
page
.
$
(
'
#
increment-btn
'
)
const
incrementBtn
=
await
page
.
$
(
'
.
increment-btn
'
)
await
incrementBtn
.
tap
()
expect
(
await
fooNum
.
text
()).
toBe
(
'
num from component Foo: 1
'
)
...
...
pages/composition-api/basic/define-expose/define-expose.uvue
浏览文件 @
3a44faca
...
...
@@ -3,7 +3,7 @@
<define-expose-foo ref='fooRef' />
<text id="foo-str" class="uni-common-mt">str from component Foo: {{fooStr}}</text>
<text id="foo-num" class="uni-common-mt">num from component Foo: {{fooNum}}</text>
<button
id="increment-btn" class="uni-common-mt
" @click="increment">trigger Foo increment</button>
<button
class="increment-btn uni-panel-h-on
" @click="increment">trigger Foo increment</button>
</view>
</template>
...
...
pages/composition-api/basic/use-slots/Foo.uvue
浏览文件 @
3a44faca
...
...
@@ -4,7 +4,7 @@
<slot :msg="msg"></slot>
<slot name="footer" :arr="arr"></slot>
<text id="check-use-slots-res" class="uni-common-mt">check useSlots result: {{ checkUseSlotsRes }}</text>
<button
id="check-use-slots-btn" class="
uni-common-mt" @click="checkUseSlots">
<button
class="check-use-slots-btn
uni-common-mt" @click="checkUseSlots">
check useSlots
</button>
</view>
...
...
pages/composition-api/basic/use-slots/use-slots.test.js
浏览文件 @
3a44faca
...
...
@@ -14,12 +14,12 @@ describe('useSlots', () => {
expect
(
await
slotContent
.
text
()).
toBe
(
'
default slot msg: default msg
'
)
const
slotFooter
=
await
page
.
$
(
'
#slot-footer
'
)
expect
(
await
slotFooter
.
text
(
)).
toBe
(
'
footer slot arr: ["a","b","c"]
'
)
expect
(
(
await
slotFooter
.
text
()).
replaceAll
(
'
\n
'
,
''
)).
toBe
(
'
footer slot arr: ["a","b","c"]
'
)
const
checkUseSlotsRes
=
await
page
.
$
(
'
#check-use-slots-res
'
)
expect
(
await
checkUseSlotsRes
.
text
()).
toBe
(
'
check useSlots result: false
'
)
const
checkUseSlotsBtn
=
await
page
.
$
(
'
#
check-use-slots-btn
'
)
const
checkUseSlotsBtn
=
await
page
.
$
(
'
.
check-use-slots-btn
'
)
await
checkUseSlotsBtn
.
tap
()
expect
(
await
checkUseSlotsRes
.
text
()).
toBe
(
'
check useSlots result: true
'
)
...
...
pages/composition-api/dependency-injection/provide/inject.uvue
浏览文件 @
3a44faca
...
...
@@ -7,7 +7,7 @@
<text class="uni-common-mt arr">arr: {{arr}}</text>
<text class="uni-common-mt fn">fn: {{(fn as () => string)()}}</text>
<text class="uni-common-mt has-injection-context">hasInjectionContext:
{{checkHasInjectionContextRes}}</text>
{{checkHasInjectionContextRes}}</text>
<button class="uni-common-mt check-has-injection-context-btn" @click="checkHasInjectionContext">check hasInjectionContext</button>
</view>
</template>
...
...
@@ -17,12 +17,15 @@
const num = inject('num')
const obj = inject('obj')
const arr = inject('arr')
const fn = inject('fn')
const fn = inject('fn')
const checkHasInjectionContextRes = ref('')
const checkHasInjectionContext = () => {
// TODO: web vue 版本低导致 hasInjectionContext 不支持, 待支持后调整
// #ifdef APP
checkHasInjectionContextRes.value = `${hasInjectionContext()}`
}
// #endif
}
checkHasInjectionContext()
</script>
\ No newline at end of file
pages/composition-api/dependency-injection/provide/provide-inject.test.js
浏览文件 @
3a44faca
...
...
@@ -23,12 +23,14 @@ describe('provide-inject-hasInjectionContext', () => {
const
fn
=
await
page
.
$
(
'
.fn
'
)
expect
(
await
fn
.
text
()).
toBe
(
'
fn: hello
'
)
const
hasInjectionContext
=
await
page
.
$
(
'
.has-injection-context
'
)
expect
(
await
hasInjectionContext
.
text
()).
toBe
(
'
hasInjectionContext: true
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
const
hasInjectionContext
=
await
page
.
$
(
'
.has-injection-context
'
)
expect
(
await
hasInjectionContext
.
text
()).
toBe
(
'
hasInjectionContext: true
'
)
const
checkHasInjectionContextBtn
=
await
page
.
$
(
'
.check-has-injection-context-btn
'
)
await
checkHasInjectionContextBtn
.
tap
()
expect
(
await
hasInjectionContext
.
text
()).
toBe
(
'
hasInjectionContext: false
'
)
const
checkHasInjectionContextBtn
=
await
page
.
$
(
'
.check-has-injection-context-btn
'
)
await
checkHasInjectionContextBtn
.
tap
()
expect
(
await
hasInjectionContext
.
text
()).
toBe
(
'
hasInjectionContext: false
'
)
}
})
})
\ No newline at end of file
pages/composition-api/reactivity/custom-ref/custom-ref.test.js
浏览文件 @
3a44faca
...
...
@@ -10,14 +10,17 @@ describe('customRef', () => {
const
stateCount
=
await
page
.
$
(
'
#state-count
'
)
expect
(
await
stateCount
.
text
()).
toBe
(
'
state.count: 0
'
)
const
incrementBtn
=
await
page
.
$
(
'
#
increment-btn
'
)
const
incrementBtn
=
await
page
.
$
(
'
.
increment-btn
'
)
await
incrementBtn
.
tap
()
expect
(
await
stateCount
.
text
()).
toBe
(
'
state.count: 0
'
)
// TODO: web 暂不支持 triggerRef
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
const
triggerRefBtn
=
await
page
.
$
(
'
.trigger-ref-btn
'
)
await
triggerRefBtn
.
tap
()
const
triggerRefBtn
=
await
page
.
$
(
'
#trigger-ref-btn
'
)
await
triggerRefBtn
.
tap
()
expect
(
await
stateCount
.
text
()).
toBe
(
'
state.count: 1
'
)
expect
(
await
stateCount
.
text
()).
toBe
(
'
state.count: 1
'
)
}
})
})
\ No newline at end of file
pages/composition-api/reactivity/custom-ref/custom-ref.uvue
浏览文件 @
3a44faca
<template>
<view class="page">
<text id="state-count">state.count: {{state['count']}}</text>
<button class="uni-common-mt
" id="
increment-btn" @click="increment">increment state.count</button>
<button class="uni-common-mt
" id="
trigger-ref-btn" @click="triggerRefState">triggerRef state</button>
<button class="uni-common-mt
increment-btn" @click="increment">increment state.count</button>
<button class="uni-common-mt
trigger-ref-btn" @click="triggerRefState">triggerRef state</button>
</view>
</template>
...
...
pages/composition-api/reactivity/reactive/reactive.test.js
浏览文件 @
3a44faca
...
...
@@ -17,14 +17,14 @@ describe('reactive', () => {
expect
(
await
objNum
.
text
()).
toBe
(
'
obj.num: 0
'
)
const
objArr
=
await
page
.
$
(
'
#obj-arr
'
)
expect
(
await
objArr
.
text
(
)).
toBe
(
'
obj.arr: ["a","b","c"]
'
)
expect
(
(
await
objArr
.
text
()).
replaceAll
(
'
\n
'
,
''
)).
toBe
(
'
obj.arr: ["a","b","c"]
'
)
const
updateBtn
=
await
page
.
$
(
'
#
update-btn
'
)
const
updateBtn
=
await
page
.
$
(
'
.
update-btn
'
)
await
updateBtn
.
tap
()
expect
(
await
count
.
text
()).
toBe
(
'
count: 2
'
)
expect
(
await
objStr
.
text
()).
toBe
(
'
obj.str: new str
'
)
expect
(
await
objNum
.
text
()).
toBe
(
'
obj.num: 2
'
)
expect
(
await
objArr
.
text
(
)).
toBe
(
'
obj.arr: ["a","b","c","d"]
'
)
expect
(
(
await
objArr
.
text
()).
replaceAll
(
'
\n
'
,
''
)).
toBe
(
'
obj.arr: ["a","b","c","d"]
'
)
})
})
\ No newline at end of file
pages/composition-api/reactivity/reactive/reactive.uvue
浏览文件 @
3a44faca
...
...
@@ -4,7 +4,7 @@
<text id="obj-str" class="uni-common-mb">obj.str: {{obj['str']}}</text>
<text id="obj-num" class="uni-common-mb">obj.num: {{obj['num']}}</text>
<text id="obj-arr" class="uni-common-mb">obj.arr: {{obj['arr']}}</text>
<button
id
="update-btn" @click="update">update</button>
<button
class
="update-btn" @click="update">update</button>
</view>
</template>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录