Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
6e761430
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
349
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看板
提交
6e761430
编写于
5月 10, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(render): 补充组合式 API
上级
78f20dcb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
86 addition
and
20 deletion
+86
-20
pages.json
pages.json
+8
-2
pages/index/index.uvue
pages/index/index.uvue
+12
-1
pages/render-function/render/render-composition.uvue
pages/render-function/render/render-composition.uvue
+36
-0
pages/render-function/render/render-options.uvue
pages/render-function/render/render-options.uvue
+0
-0
pages/render-function/render/render.test.js
pages/render-function/render/render.test.js
+30
-17
未找到文件。
pages.json
浏览文件 @
6e761430
...
...
@@ -711,9 +711,15 @@
}
},
{
"path"
:
"pages/render-function/render/render"
,
"path"
:
"pages/render-function/render/render
-options
"
,
"style"
:
{
"navigationBarTitleText"
:
"render function"
"navigationBarTitleText"
:
"render 选项式 API"
}
},
{
"path"
:
"pages/render-function/render/render-composition"
,
"style"
:
{
"navigationBarTitleText"
:
"render 组合式 API"
}
},
{
...
...
pages/index/index.uvue
浏览文件 @
6e761430
...
...
@@ -976,7 +976,18 @@ export default {
{
id: 'render',
name: 'render & h()',
url: 'render/render'
children: [
{
id: 'render-options',
name: 'render 选项式 API',
url: 'render-options'
},
{
id: 'render-composition',
name: 'render 组合式 API',
url: 'render-composition'
},
]
},
{
id: 'mergeProps',
...
...
pages/render-function/render/render-composition.uvue
0 → 100644
浏览文件 @
6e761430
<script setup lang="uts">
import CompForHFunction from '@/components/CompForHFunction.uvue'
defineOptions({
data() {
return {
msg: 'default msg'
}
},
render(): VNode {
const instance = getCurrentInstance()!.proxy!
return h('view', { class: 'page' }, [
h(CompForHFunction, {}, (): VNode[] => [h('text', { class: 'comp-slot' }, 'component slot')]),
h('text', { class: 'uni-common-mt msg', style: { color: 'blue' } }, instance.$data['msg']),
h(
'button',
{
class: 'uni-common-mt btn',
type: 'primary',
onClick: () => {
instance.$data['msg'] = 'new msg'
}
},
'click'
)
])
}
})
</script>
<style>
.btn {
color: red;
}
</style>
\ No newline at end of file
pages/render-function/render/render.uvue
→
pages/render-function/render/render
-options
.uvue
浏览文件 @
6e761430
文件已移动
pages/render-function/render/render.test.js
浏览文件 @
6e761430
const
PAGE_PATH
=
'
/pages/render-function/render/render
'
const
OPTIONS_PAGE_PATH
=
'
/pages/render-function/render/render-options
'
const
COMPOSITION_PAGE_PATH
=
'
/pages/render-function/render/render-composition
'
describe
(
'
/pages/render-function/render/render
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
// TODO: web 端测试未获取到元素
it
(
'
web
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
describe
(
'
render-function render
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
if
(
isWeb
)
{
it
(
"
web platform test cannot get render dom
"
,
async
()
=>
{
expect
(
1
).
toBe
(
1
);
});
return
}
let
page
beforeAll
(
async
(
)
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
const
test
=
async
(
pagePath
)
=>
{
page
=
await
program
.
reLaunch
(
pagePath
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
component
'
,
async
()
=>
{
const
ComForRenderFunction
=
await
page
.
$
(
'
.component-for-h-function
'
)
expect
(
await
ComForRenderFunction
.
text
()).
toEqual
(
'
component for h()
'
)
const
compSlot
=
await
page
.
$
(
'
.comp-slot
'
)
expect
(
await
compSlot
.
text
()).
toEqual
(
'
component slot
'
)
})
it
(
'
text
'
,
async
()
=>
{
const
msgEl
=
await
page
.
$
(
'
.msg
'
)
let
msgEl
=
await
page
.
$
(
'
.msg
'
)
expect
(
await
msgEl
.
text
()).
toEqual
(
'
default msg
'
)
})
it
(
'
button
'
,
async
()
=>
{
const
btnEl
=
await
page
.
$
(
'
.btn
'
)
expect
(
await
btnEl
.
property
(
'
type
'
)).
toBe
(
'
primary
'
)
await
btnEl
.
tap
()
const
msgEl
=
await
page
.
$
(
'
.msg
'
)
msgEl
=
await
page
.
$
(
'
.msg
'
)
expect
(
await
msgEl
.
text
()).
toEqual
(
'
new msg
'
)
}
it
(
'
render options API
'
,
async
()
=>
{
await
test
(
OPTIONS_PAGE_PATH
)
})
it
(
'
render composition API
'
,
async
()
=>
{
if
(
!
isIos
)
{
await
test
(
COMPOSITION_PAGE_PATH
)
}
else
{
// TODO: ios 端 defineOptions + render 页面空白
expect
(
1
).
toBe
(
1
);
}
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录