Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
4942652c
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
402
Star
3
Fork
10
代码
文件
提交
分支
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看板
提交
4942652c
编写于
10月 25, 2023
作者:
Y
yurj26
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增插槽测试例
上级
b457a8b5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
121 addition
and
112 deletion
+121
-112
pages/component-instance/slots/slot.uvue
pages/component-instance/slots/slot.uvue
+28
-26
pages/component-instance/slots/slots.uvue
pages/component-instance/slots/slots.uvue
+28
-27
pages/rendering/slots/child.uvue
pages/rendering/slots/child.uvue
+32
-26
pages/rendering/slots/slots.uvue
pages/rendering/slots/slots.uvue
+33
-33
未找到文件。
pages/component-instance/slots/slot.uvue
浏览文件 @
4942652c
<template>
<view>
<slot name="header"></slot>
<slot name="footer"></slot>
</view>
</template>
<script>
export default {
mounted () {
console.log(this.hasSlots())
},
methods: {
hasSlots (): boolean {
const header = this.$slots.get('header')
const footer = this.$slots.get('footer')
return header !== null && footer !== null
}
}
}
</script>
<style scoped>
</style>
<template>
<view>
<slot name="header"></slot>
<slot name="footer"></slot>
<slot></slot>
</view>
</template>
<script lang="uts">
export default {
mounted() {
console.log(this.hasSlots())
},
methods: {
hasSlots() : boolean {
const header = this.$slots['header']
const footer = this.$slots['footer']
const def = this.$slots['default']
return header !== null && footer !== null && def !== null
}
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
pages/component-instance/slots/slots.uvue
浏览文件 @
4942652c
<template>
<view class="page">
<slot-comp class="slot-comp">
<template v-slot:header>header</template>
<template v-slot:footer>footer</template>
</slot-comp>
</view>
</template>
<script>
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;
}
</style>
<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;
}
</style>
\ No newline at end of file
pages/rendering/slots/child.uvue
浏览文件 @
4942652c
<template>
<view class="container">
<view>
<slot name="header"></slot>
</view>
<view>
<slot></slot>
</view>
<view>
<slot name="footer"></slot>
</view>
</view>
</template>
<script>
export default {
name:"child",
data() {
return {}
},
methods: {}
}
</script>
<style>
<template>
<view class="container">
<view>
<slot name="header" msg="Here might be a page title"></slot>
</view>
<view>
<slot msg="A paragraph for the main content."></slot>
</view>
<view>
<slot name="footer" msg="Here's some contact info"></slot>
</view>
</view>
</template>
<script lang="uts">
import { SlotsType } from 'vue'
export default {
name: "child",
slots: Object as SlotsType<{
header : { msg : string },
default : { msg : string },
footer : { msg : string }
}>,
data() {
return {}
},
methods: {}
}
</script>
<style>
</style>
\ No newline at end of file
pages/rendering/slots/slots.uvue
浏览文件 @
4942652c
<template>
<view class="content">
<child>
<template v-slot:header>
<view class="header">Here might be a page title</view>
</template>
<template v-slot:default>
<view class="main">A paragraph for the main content.</view>
</template>
<template v-slot:footer>
<view class="footer">Here's some contact info</view>
</template>
</child>
</view>
</template>
<script
>
import child from './child.uvue';
export default {
components:{child},
data() {
return {}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
<template>
<view class="content">
<child>
<template v-slot:header="slotProps">
<view class="header">{{ slotProps.msg }}</view>
</template>
<template v-slot:default="{ msg }">
<view class="main">{{ msg }}</view>
</template>
<template #footer="{ msg: text }">
<view class="footer">{{ text }}</view>
</template>
</child>
</view>
</template>
<script
lang="uts">
import child from './child.uvue';
export default {
components: { child },
data() {
return {}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
</style>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录