Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navigateTo 回调 success 入参的类型缺少 eventChannel #8506

Closed
Aysnine opened this issue Jan 12, 2021 · 1 comment
Closed

navigateTo 回调 success 入参的类型缺少 eventChannel #8506

Aysnine opened this issue Jan 12, 2021 · 1 comment
Assignees
Labels
A-typings Area - TypeScript Typings 相关 enhancement New feature or request
Milestone

Comments

@Aysnine
Copy link
Contributor

Aysnine commented Jan 12, 2021

这个特性解决了什么问题?

希望官方补充一下 navigateTo 回调 success 入参的类型,否则会遇到如下情况:

   navigateTo({
      url: `/pages/comment/comment`,
      success: (res) => {
        // Property 'eventChannel' does not exist on type 'CallbackResult'.ts(2339)
        res.eventChannel.emit('TARGET-ORDER', order);
      }
    });

此处在实际运行中,是能获取到 eventChannel 的

这个 API 长什么样?

原代码:

success?: (res: General.CallbackResult) => void

改为如下:

  namespace navigateTo {
    interface Option {
      /** 需要跳转的应用内非 tabBar 的页面的路径, 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */
      url: string
      /** 接口调用结束的回调函数(调用成功、失败都会执行) */
      complete?: (res: General.CallbackResult) => void
      /** 页面间通信接口,用于监听被打开页面发送到当前页面的数据。 */
      events?: General.IAnyObject
      /** 接口调用失败的回调函数 */
      fail?: (res: General.CallbackResult) => void
      /** 接口调用成功的回调函数 */
      success?: (res: General.CallbackResult & { eventChannel?: EventChannel }) => void
    }
  }
@taro-bot2 taro-bot2 bot added the enhancement New feature or request label Jan 12, 2021
@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 13, 2021

@Aysnine 来个 PR 咯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typings Area - TypeScript Typings 相关 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants