Skip to content

Commit

Permalink
fix:修复Taro-路由navigateTo返回参数中缺失了eventChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
StarJacky committed Sep 19, 2023
1 parent eba6419 commit 7332378
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/taro-router/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ async function navigate (option: Option | NavigateBackOption, method: MethodName
return new Promise<TaroGeneral.CallbackResult>((resolve, reject) => {
stacks.method = method
const { success, complete, fail } = option
const eventChannel : TaroGeneral.eventChannel = {
emit (): void{},
on (): void{},
once (): void{},
off (): void{}
}
const unListen = history.listen(() => {
const res = { errMsg: `${method}:ok` }
const res = {
errMsg: `${method}:ok` ,
eventChannel : eventChannel
}
success?.(res)
complete?.(res)
resolve(res)
Expand Down
28 changes: 28 additions & 0 deletions packages/taro/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,34 @@ declare namespace TaroGeneral {
trigger (eventName: EventName, ...args: any[]): this
}

class eventChannel implements EventChannel {
constructor() {
}
emit(
/** 事件名称 */
eventName: string,
/** 事件参数 */
...args: any
): void
on(
/** 事件名称 */
eventName: string,
/** 事件监听函数 */
fn: TaroGeneral.EventCallback,
): void
once(
/** 事件名称 */
eventName: string,
/** 事件监听函数 */
fn: TaroGeneral.EventCallback,
): void
off(
/** 事件名称 */
eventName: string,
/** 事件监听函数 */
fn: TaroGeneral.EventCallback,
): void
}
// ENV_TYPE
enum ENV_TYPE {
WEAPP = 'WEAPP',
Expand Down

0 comments on commit 7332378

Please sign in to comment.