Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
58f95fd2
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看板
提交
58f95fd2
编写于
4月 25, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(directive): v-slot & defineSlots
上级
51fefce5
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
147 addition
and
61 deletion
+147
-61
pages.json
pages.json
+7
-3
pages/directive/v-slot/Foo-composition.uvue
pages/directive/v-slot/Foo-composition.uvue
+19
-0
pages/directive/v-slot/Foo-options.uvue
pages/directive/v-slot/Foo-options.uvue
+24
-0
pages/directive/v-slot/counter.uvue
pages/directive/v-slot/counter.uvue
+0
-27
pages/directive/v-slot/v-slot-composition.uvue
pages/directive/v-slot/v-slot-composition.uvue
+28
-0
pages/directive/v-slot/v-slot-options.uvue
pages/directive/v-slot/v-slot-options.uvue
+31
-0
pages/directive/v-slot/v-slot.test.js
pages/directive/v-slot/v-slot.test.js
+22
-7
pages/directive/v-slot/v-slot.uvue
pages/directive/v-slot/v-slot.uvue
+0
-24
pages/index/index.uvue
pages/index/index.uvue
+16
-0
未找到文件。
pages.json
浏览文件 @
58f95fd2
...
...
@@ -265,14 +265,18 @@
"navigationBarTitleText"
:
"defineModel"
}
},
{
"path"
:
"pages/directive/v-slot/v-slot"
,
"path"
:
"pages/directive/v-slot/v-slot
-options
"
,
"style"
:
{
"navigationBarTitleText"
:
"v-slot"
}
},
{
"path"
:
"pages/directive/v-slot/v-slot-composition"
,
"style"
:
{
"navigationBarTitleText"
:
"defineSlots"
}
},
{
"path"
:
"pages/component-instance/slots/slots-options"
,
"style"
:
{
...
...
pages/directive/v-slot/Foo-composition.uvue
0 → 100644
浏览文件 @
58f95fd2
<template>
<view>
<slot name="header" :msg="msg"></slot>
<slot :num="num"></slot>
<slot name="footer" :arr="arr"></slot>
</view>
</template>
<script setup lang='uts'>
const msg = ref('foo msg')
const num = ref<number>(0)
const arr = ref<string[]>(['a', 'b', 'c'])
defineSlots<{
header(props : { msg : string }) : any,
default(props : { num : number }) : any,
footer(props : { arr : string[] }) : any
}>()
</script>
pages/directive/v-slot/Foo-options.uvue
0 → 100644
浏览文件 @
58f95fd2
<template>
<view>
<slot name="header" :msg="msg"></slot>
<slot :num="num"></slot>
<slot name="footer" :arr="arr"></slot>
</view>
</template>
<script lang="uts">
export default {
slots: Object as SlotsType<{
header: { msg: string }
default: { num: number }
footer: { arr: string[] }
}>,
data(){
return {
msg: 'foo msg',
num: 0,
arr: ['a','b', 'c']
}
}
}
</script>
pages/directive/v-slot/counter.uvue
已删除
100644 → 0
浏览文件 @
51fefce5
<template>
<view>
<slot />
<!-- <slot :loading="loading" :error="message" /> -->
</view>
</template>
<script>
export default {
props: {
number: {
type: Number,
default: 0
}
},
data() {
return {
loading: false,
message: ''
}
},
created() {
},
methods: {
}
}
</script>
\ No newline at end of file
pages/directive/v-slot/v-slot-composition.uvue
0 → 100644
浏览文件 @
58f95fd2
<template>
<view class="page">
<Foo>
<template #header="{ msg }">
<view class="mb-10 flex justify-between flex-row">
<text>header slot msg:</text>
<text id="slot-header">{{ msg }}</text>
</view>
</template>
<template #default="{ num }">
<view class="mb-10 flex justify-between flex-row">
<text>default slot num:</text>
<text id="slot-default">{{ num }}</text>
</view>
</template>
<template #footer="{ arr }">
<view class="mb-10 flex justify-between flex-row">
<text>footer slot arr:</text>
<text id="slot-footer">{{ JSON.stringify(arr) }}</text>
</view>
</template>
</Foo>
</view>
</template>
<script setup lang="uts">
import Foo from './Foo-composition.uvue'
</script>
pages/directive/v-slot/v-slot-options.uvue
0 → 100644
浏览文件 @
58f95fd2
<template>
<view class="page">
<Foo>
<template #header="{ msg }">
<view class="mb-10 flex justify-between flex-row">
<text>header slot msg:</text>
<text id="slot-header">{{ msg }}</text>
</view>
</template>
<template #default="{ num }">
<view class="mb-10 flex justify-between flex-row">
<text>default slot num:</text>
<text id="slot-default">{{ num }}</text>
</view>
</template>
<template #footer="{ arr }">
<view class="mb-10 flex justify-between flex-row">
<text>footer slot arr:</text>
<text id="slot-footer">{{ JSON.stringify(arr) }}</text>
</view>
</template>
</Foo>
</view>
</template>
<script lang="uts">
import Foo from './Foo-options.uvue'
export default {
components: {Foo}
}
</script>
pages/directive/v-slot/v-slot.test.js
浏览文件 @
58f95fd2
const
PAGE_PATH
=
'
/pages/directive/v-slot/v-slot
'
const
OPTIONS_PAGE_PATH
=
'
/pages/directive/v-slot/v-slot-options
'
const
COMPOSITION_PAGE_PATH
=
'
/pages/directive/v-slot/v-slot-composition
'
describe
(
'
v-slot
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
const
test
=
async
(
pagePath
)
=>
{
page
=
await
program
.
reLaunch
(
pagePath
)
await
page
.
waitFor
(
'
view
'
)
const
slotHeader
=
await
page
.
$
(
'
#slot-header
'
)
expect
(
await
slotHeader
.
text
()).
toBe
(
'
foo msg
'
)
const
slotContent
=
await
page
.
$
(
'
#slot-default
'
)
expect
(
await
slotContent
.
text
()).
toBe
(
'
0
'
)
const
slotFooter
=
await
page
.
$
(
'
#slot-footer
'
)
expect
(
await
slotFooter
.
text
()).
toBe
(
'
["a","b","c"]
'
)
}
it
(
'
v-slot
'
,
async
()
=>
{
await
test
(
OPTIONS_PAGE_PATH
)
})
it
(
'
default
'
,
async
()
=>
{
const
defaultText
=
await
page
.
$
(
'
.default
'
)
expect
(
await
defaultText
.
text
()).
toBe
(
'
loading
'
)
it
(
'
defineSlots
'
,
async
()
=>
{
await
test
(
COMPOSITION_PAGE_PATH
)
})
})
pages/directive/v-slot/v-slot.uvue
已删除
100644 → 0
浏览文件 @
51fefce5
<template>
<view class="page">
<view class="split-title">v-slot</view>
<counter class="default" v-slot:default>loading</counter>
</view>
</template>
<script>
import counter from "./counter.uvue"
export default {
components: {
counter
},
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
\ No newline at end of file
pages/index/index.uvue
浏览文件 @
58f95fd2
...
...
@@ -822,6 +822,22 @@ export default {
},
]
},
{
id: 'v-slot',
name: 'v-slot',
children: [
{
id: 'v-model-options',
name: 'v-slot',
url: 'v-slot-options',
},
{
id: 'v-slot-composition',
name: 'defineSlots',
url: 'v-slot-composition',
},
]
},
]
},
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录