Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
ce42d106
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
359
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看板
提交
ce42d106
编写于
4月 17, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(component-instance): $slots
上级
fa5dc483
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
119 addition
and
46 deletion
+119
-46
pages.json
pages.json
+7
-1
pages/component-instance/slots/slot-composition.uvue
pages/component-instance/slots/slot-composition.uvue
+23
-0
pages/component-instance/slots/slot-options.uvue
pages/component-instance/slots/slot-options.uvue
+0
-0
pages/component-instance/slots/slots-composition.uvue
pages/component-instance/slots/slots-composition.uvue
+22
-0
pages/component-instance/slots/slots-options.uvue
pages/component-instance/slots/slots-options.uvue
+27
-27
pages/component-instance/slots/slots.test.js
pages/component-instance/slots/slots.test.js
+10
-4
pages/index/index.uvue
pages/index/index.uvue
+30
-14
未找到文件。
pages.json
浏览文件 @
ce42d106
...
...
@@ -298,7 +298,13 @@
}
},
{
"path"
:
"pages/component-instance/slots/slots"
,
"path"
:
"pages/component-instance/slots/slots-options"
,
"style"
:
{
"navigationBarTitleText"
:
"$slots"
}
},
{
"path"
:
"pages/component-instance/slots/slots-composition"
,
"style"
:
{
"navigationBarTitleText"
:
"$slots"
}
...
...
pages/component-instance/slots/slot-composition.uvue
0 → 100644
浏览文件 @
ce42d106
<template>
<view>
<slot name="header"></slot>
<slot name="footer"></slot>
<slot></slot>
</view>
</template>
<script setup lang="uts">
const slots = useSlots()
const hasSlots = (): boolean => {
const header = slots['header']
const footer = slots['footer']
const def = slots['default']
return header !== null && footer !== null && def !== null
}
defineExpose({
hasSlots
})
</script>
\ No newline at end of file
pages/component-instance/slots/slot.uvue
→
pages/component-instance/slots/slot
-options
.uvue
浏览文件 @
ce42d106
文件已移动
pages/component-instance/slots/slots-composition.uvue
0 → 100644
浏览文件 @
ce42d106
<template>
<view class="page">
<SlotComp class="slot-comp">
<template v-slot:header>header</template>
<template v-slot:default>default</template>
<template v-slot:footer>footer</template>
</SlotComp>
</view>
</template>
<script setup lang="uts">
import SlotComp from './slot-composition.uvue'
</script>
<style>
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 10px;
}
</style>
\ No newline at end of file
pages/component-instance/slots/slots.uvue
→
pages/component-instance/slots/slots
-options
.uvue
浏览文件 @
ce42d106
<template>
<view class="page">
<slot-comp class="slot-comp">
<template v-slot:header>header</template>
<template v-slot:default>default</template>
<template v-slot:footer>footer</template>
</slot-comp>
</view>
</template>
<script lang="uts">
import slot from './slot
.uvue'
export default {
components: {
slotComp: slot
}
}
</script>
<style>
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 10px;
}
<template>
<view class="page">
<slot-comp class="slot-comp">
<template v-slot:header>header</template>
<template v-slot:default>default</template>
<template v-slot:footer>footer</template>
</slot-comp>
</view>
</template>
<script lang="uts">
import slot from './slot
-options.uvue'
export default {
components: {
slotComp: slot
}
}
</script>
<style>
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 10px;
}
</style>
\ No newline at end of file
pages/component-instance/slots/slots.test.js
浏览文件 @
ce42d106
const
PAGE_PATH
=
'
/pages/component-instance/slots/slots
'
const
PAGE_PATH
=
'
/pages/component-instance/slots/slots-options
'
const
PAGE_COMPOSITION_PATH
=
'
/pages/component-instance/slots/slots-composition
'
describe
(
'
$slots
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
it
(
'
$slots Options API 生效
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
const
slotComp
=
await
page
.
$
(
'
.slot-comp
'
)
const
hasSlots
=
await
slotComp
.
callMethod
(
'
hasSlots
'
)
expect
(
hasSlots
).
toBe
(
true
)
})
it
(
'
$slots 生效
'
,
async
()
=>
{
it
(
'
$slots Composition API 生效
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_COMPOSITION_PATH
)
await
page
.
waitFor
(
500
)
const
slotComp
=
await
page
.
$
(
'
.slot-comp
'
)
const
hasSlots
=
await
slotComp
.
callMethod
(
'
hasSlots
'
)
expect
(
hasSlots
).
toBe
(
true
)
})
})
pages/index/index.uvue
浏览文件 @
ce42d106
...
...
@@ -215,8 +215,24 @@ export default {
url: 'root-composition'
}
]
}
}
,
// #endif
{
id: 'slots',
name: '$slots',
children: [
{
id: 'slots-options',
name: '$slots 选项式 API',
url: 'slots-options'
},
{
id: 'slots-composition',
name: '$slots 组合式 API',
url: 'slots-composition'
}
]
}
] as Page[]
},
{
...
...
@@ -229,13 +245,13 @@ export default {
children: [
{
id: 'page-options',
name: '页面生命周期
(选项式)
',
name: '页面生命周期
选项式 API
',
url: 'page-options'
},
{
id: 'page-composition',
name: '页面生命周期
(组合式)
',
name: '页面生命周期
组合式 API
',
url: 'page-composition'
}
]
...
...
@@ -252,13 +268,13 @@ export default {
children: [
{
id: 'keep-alive-options',
name: 'keep-alive
(选项式)
',
name: 'keep-alive
选项式 API
',
url: 'keep-alive-options'
},
{
id: 'keep-alive-composition',
name: 'keep-alive
(组合式)
',
name: 'keep-alive
组合式 API
',
url: 'keep-alive-composition'
}
]
...
...
@@ -269,13 +285,13 @@ export default {
children: [
{
id: 'teleport-options',
name: 'teleport
(选项式)
',
name: 'teleport
选项式 API
',
url: 'teleport-options'
},
{
id: 'teleport-composition',
name: 'teleport
(组合式)
',
name: 'teleport
组合式 API
',
url: 'teleport-composition'
}
]
...
...
@@ -286,13 +302,13 @@ export default {
children: [
{
id: 'component-options',
name: 'component
(选项式)
',
name: 'component
选项式 API
',
url: 'component-options'
},
{
id: 'component-composition',
name: 'component
(组合式)
',
name: 'component
组合式 API
',
url: 'component-composition'
}
]
...
...
@@ -303,13 +319,13 @@ export default {
children: [
{
id: 'slots-options',
name: 'slots
(选项式)
',
name: 'slots
选项式 API
',
url: 'slots-options'
},
{
id: 'slots-composition',
name: 'slots
(组合式)
',
name: 'slots
组合式 API
',
url: 'slots-composition'
}
]
...
...
@@ -320,13 +336,13 @@ export default {
children: [
{
id: 'template-options',
name: 'template
(选项式)
',
name: 'template
选项式 API
',
url: 'template-options'
},
{
id: 'template-composition',
name: 'template
(组合式)
',
name: 'template
组合式 API
',
url: 'template-composition'
}
]
...
...
@@ -339,7 +355,7 @@ export default {
pages: [
{
id: 'render',
name: 'render Function
(选项式)
',
name: 'render Function
选项式 API
',
url: 'render/render'
},
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录