Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
129bee85
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
129bee85
编写于
7月 07, 2023
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add event bus test
上级
647b2858
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
119 addition
and
0 deletion
+119
-0
pages.json
pages.json
+6
-0
pages/API/event-bus/event-bus.test.js
pages/API/event-bus/event-bus.test.js
+54
-0
pages/API/event-bus/event-bus.uvue
pages/API/event-bus/event-bus.uvue
+51
-0
pages/tabBar/API.uvue
pages/tabBar/API.uvue
+8
-0
未找到文件。
pages.json
浏览文件 @
129bee85
...
...
@@ -561,6 +561,12 @@
"navigationBarTitleText"
:
"pageScrollTo"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/API/event-bus/event-bus"
,
"style"
:
{
"navigationBarTitleText"
:
"event-bus"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/template/drop-card/drop-card"
,
"style"
:
{
...
...
pages/API/event-bus/event-bus.test.js
0 → 100644
浏览文件 @
129bee85
const
PAGE_PATH
=
'
/pages/API/event-bus/event-bus
'
describe
(
'
event-bus
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
on
'
,
async
()
=>
{
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
on
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l1
=
(
await
page
.
data
()).
log
.
length
expect
(
l1
).
toBe
(
1
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l2
=
(
await
page
.
data
()).
log
.
length
expect
(
l2
).
toBe
(
1
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
on
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l3
=
(
await
page
.
data
()).
log
.
length
expect
(
l3
).
toBe
(
2
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
off
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l4
=
(
await
page
.
data
()).
log
.
length
expect
(
l4
).
toBe
(
1
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
off
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l5
=
(
await
page
.
data
()).
log
.
length
expect
(
l5
).
toBe
(
0
)
})
it
(
'
once
'
,
async
()
=>
{
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
once
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l1
=
(
await
page
.
data
()).
log
.
length
expect
(
l1
).
toBe
(
1
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l2
=
(
await
page
.
data
()).
log
.
length
expect
(
l2
).
toBe
(
0
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
once
'
)
await
page
.
callMethod
(
'
off
'
)
await
page
.
callMethod
(
'
emit
'
)
const
l3
=
(
await
page
.
data
()).
log
.
length
expect
(
l3
).
toBe
(
0
)
})
})
pages/API/event-bus/event-bus.uvue
0 → 100644
浏览文件 @
129bee85
<template>
<view>
<button @click="on">开始监听</button>
<button @click="once">监听一次</button>
<button @click="off">取消监听</button>
<button @click="emit">触发监听</button>
<button @click="clear">清空消息</button>
<view class="box">
<view>收到的消息:</view>
<view>
<view v-for="(item, index) in log" :key="index">{{ item }}</view>
</view>
</view>
</view>
</template>
<script lang="ts">
export default {
data() {
return {
log: [] as string[]
}
},
methods: {
fn(res: string) {
this.log.push(res)
},
on() {
uni.$on('test', this.fn)
},
once() {
uni.$once('test', this.fn)
},
off() {
uni.$off('test', this.fn)
},
emit() {
uni.$emit('test', 'msg:' + Date.now())
},
clear() {
this.log.length = 0
}
}
}
</script>
<style>
.box {
padding: 10px;
}
</style>
\ No newline at end of file
pages/tabBar/API.uvue
浏览文件 @
129bee85
...
...
@@ -456,6 +456,14 @@
url: "/platforms/app-plus/push/push",
},
] as Page[],
},
{
id: "event-bus",
name: "event-bus",
open: false,
enable: true,
url: "event-bus",
pages: [] as Page[],
},
//#endif
] as ListItem[],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录