提交 0f22e7ca 编写于 作者: H hdx

fix($off): 暂时注释掉新功能,第二个可选参数

上级 34296d5d
...@@ -52,21 +52,21 @@ describe('event-bus', () => { ...@@ -52,21 +52,21 @@ describe('event-bus', () => {
expect(l3).toBe(0) expect(l3).toBe(0)
}) })
it('off-all', async () => { // it('off-all', async () => {
await page.callMethod('clear') // await page.callMethod('clear')
await page.callMethod('on') // await page.callMethod('on')
await page.callMethod('on2') // await page.callMethod('on2')
await page.callMethod('emit') // await page.callMethod('emit')
const l1 = (await page.data()).log.length // const l1 = (await page.data()).log.length
expect(l1).toBe(2) // expect(l1).toBe(2)
await page.callMethod('clear') // await page.callMethod('clear')
const l2 = (await page.data()).log.length // const l2 = (await page.data()).log.length
expect(l2).toBe(0) // expect(l2).toBe(0)
await page.callMethod('offAll') // await page.callMethod('offAll')
await page.callMethod('emit') // await page.callMethod('emit')
const l3 = (await page.data()).log.length // const l3 = (await page.data()).log.length
expect(l3).toBe(0) // expect(l3).toBe(0)
}) // })
}) })
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<button @click="on">开始监听</button> <button @click="on">开始监听</button>
<button @click="once">监听一次</button> <button @click="once">监听一次</button>
<button @click="off">取消监听</button> <button @click="off">取消监听</button>
<button @click="offAll">取消全部监听</button> <!-- <button @click="offAll">取消全部监听</button> -->
<button @click="emit">触发监听</button> <button @click="emit">触发监听</button>
<button @click="clear">清空消息</button> <button @click="clear">清空消息</button>
<view class="box"> <view class="box">
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
}, },
offAll() { offAll() {
// TODO 第二个参数为可选,后续优化后可不传递 // TODO 第二个参数为可选,后续优化后可不传递
uni.$off('test', null) //uni.$off('test', null)
}, },
emit() { emit() {
uni.$emit('test', 'msg:' + Date.now()) uni.$emit('test', 'msg:' + Date.now())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册