Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
28380dac
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
367
Star
3
Fork
8
代码
文件
提交
分支
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看板
提交
28380dac
编写于
5月 09, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(render function): cloneVNode
上级
318c2ef8
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
121 addition
and
9 deletion
+121
-9
pages.json
pages.json
+12
-0
pages/index/index.uvue
pages/index/index.uvue
+16
-0
pages/render-function/cloneVNode/cloneVNode-composition.uvue
pages/render-function/cloneVNode/cloneVNode-composition.uvue
+29
-0
pages/render-function/cloneVNode/cloneVNode-options.uvue
pages/render-function/cloneVNode/cloneVNode-options.uvue
+29
-0
pages/render-function/cloneVNode/cloneVNode.test.js
pages/render-function/cloneVNode/cloneVNode.test.js
+30
-0
pages/render-function/mergeProps/mergeProps-composition.uvue
pages/render-function/mergeProps/mergeProps-composition.uvue
+2
-4
pages/render-function/mergeProps/mergeProps-options.uvue
pages/render-function/mergeProps/mergeProps-options.uvue
+3
-5
未找到文件。
pages.json
浏览文件 @
28380dac
...
...
@@ -728,6 +728,18 @@
"navigationBarTitleText"
:
"mergeProps 组合式 API"
}
},
{
"path"
:
"pages/render-function/cloneVNode/cloneVNode-options"
,
"style"
:
{
"navigationBarTitleText"
:
"cloneVNode 选项式 API"
}
},
{
"path"
:
"pages/render-function/cloneVNode/cloneVNode-composition"
,
"style"
:
{
"navigationBarTitleText"
:
"cloneVNode 组合式 API"
}
},
{
"path"
:
"pages/examples/unrecognized-component/unrecognized-component"
,
"style"
:
{
...
...
pages/index/index.uvue
浏览文件 @
28380dac
...
...
@@ -993,6 +993,22 @@ export default {
url: 'mergeProps-composition'
},
]
},
{
id: 'cloneVNode',
name: 'cloneVNode',
children: [
{
id: 'cloneVNode-options',
name: 'cloneVNode 选项式 API',
url: 'cloneVNode-options'
},
{
id: 'cloneVNode-composition',
name: 'cloneVNode 组合式 API',
url: 'cloneVNode-composition'
},
]
}
] as Page[]
},
...
...
pages/render-function/cloneVNode/cloneVNode-composition.uvue
0 → 100644
浏览文件 @
28380dac
<script setup lang="uts">
import { cloneVNode } from 'vue'
defineOptions({
render() : VNode {
const originalVNode = h('view', { class: 'original' }, [
h('text', {}, 'Hello World'),
])
// #ifdef APP
const clonedVNode = cloneVNode(originalVNode, new Map<string, any | null>([['class', 'cloned']]))
// #endif
// #ifdef WEB
const clonedVNode = cloneVNode(originalVNode, { class: 'cloned'})
// #endif
return h('view', { class: 'flex flex-col' }, [originalVNode, clonedVNode])
}
})
</script>
<style>
.original {
background-color: #ff0000;
}
.cloned {
background-color: #00ff00;
}
</style>
\ No newline at end of file
pages/render-function/cloneVNode/cloneVNode-options.uvue
0 → 100644
浏览文件 @
28380dac
<script lang="uts">
import { cloneVNode } from 'vue'
export default {
render() : VNode {
const originalVNode = h('view', { class: 'original' }, [
h('text', {}, 'Hello World'),
])
// #ifdef APP
const clonedVNode = cloneVNode(originalVNode, new Map<string, any | null>([['class', 'cloned']]))
// #endif
// #ifdef WEB
const clonedVNode = cloneVNode(originalVNode, { class: 'cloned'})
// #endif
return h('view', { class: 'flex flex-col' }, [originalVNode, clonedVNode])
}
}
</script>
<style>
.original {
background-color: #ff0000;
}
.cloned {
background-color: #00ff00;
}
</style>
\ No newline at end of file
pages/render-function/cloneVNode/cloneVNode.test.js
0 → 100644
浏览文件 @
28380dac
const
OPTIONS_PAGE_PATH
=
'
/pages/render-function/cloneVNode/cloneVNode-options
'
const
COMPOSITION_PAGE_PATH
=
'
/pages/render-function/cloneVNode/cloneVNode-composition
'
describe
(
'
cloneVNode
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
// TODO: ios options API 合并属性无效, composition API 页面空白
it
(
"
IOS platform not support
"
,
async
()
=>
{
expect
(
1
).
toBe
(
1
);
});
return
}
let
page
=
null
const
test
=
async
(
pagePath
)
=>
{
page
=
await
program
.
reLaunch
(
pagePath
)
// 因为 web 端无法获取, 未使用 waitFor view
await
page
.
waitFor
(
1000
)
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toSaveImageSnapshot
();
}
it
(
'
cloneVNode options API
'
,
async
()
=>
{
await
test
(
OPTIONS_PAGE_PATH
)
})
it
(
'
cloneVNode composition API
'
,
async
()
=>
{
await
test
(
COMPOSITION_PAGE_PATH
)
})
})
\ No newline at end of file
pages/render-function/mergeProps/mergeProps-composition.uvue
浏览文件 @
28380dac
...
...
@@ -13,13 +13,11 @@
</template>
<script setup lang="uts">
// TODO: 确认 android 与 web & ios 差异
// #ifndef APP-ANDROID
import { mergeProps } from 'vue'
// #endif
type PropFn = () => string
// TODO: 确认 android 与 web & ios 差异
// #ifdef APP-ANDROID
const propA = new Map<string, any | null>([['class', 'foo'], ['onClick', () : string => 'propA click res']])
const propB = new Map<string, any | null>([['class', { bar: true }], ['onClick', () : string => 'propB click res']])
...
...
@@ -38,7 +36,7 @@
// #endif
const propFnResList = ref<string[]>([])
mergedProps.value = mergeProps(propA, propB)
mergedProps.value = mergeProps(propA, propB)
const triggerMergedClick = () => {
(mergedProps.value['onClick'] as PropFn[]).forEach(fn => { propFnResList.value.push(fn()) })
...
...
pages/render-function/mergeProps/mergeProps-options.uvue
浏览文件 @
28380dac
...
...
@@ -12,16 +12,14 @@
</view>
</template>
<script lang="uts">
// TODO: 确认 android 与 web & ios 差异
// #ifndef APP-ANDROID
<script lang="uts">
import { mergeProps } from 'vue'
// #endif
type PropFn = () => string
export default {
data() {
return {
// TODO: 确认 android 与 web & ios 差异
// #ifdef APP-ANDROID
propA: new Map<string, any | null>([['class', 'foo'], ['onClick', () : string => 'propA click res']]),
propB: new Map<string, any | null>([['class', { bar: true }], ['onClick', () : string => 'propB click res']]),
...
...
@@ -35,7 +33,7 @@
propB: {
class: { bar: true },
onClick: () : string => 'propB click res'
},
},
mergedProps: {},
// #endif
propFnResList: [] as string[],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录