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

this.getPageId is not a function #14127

Closed
EricLeeN1 opened this issue Jul 7, 2023 · 1 comment · Fixed by #14179
Closed

this.getPageId is not a function #14127

EricLeeN1 opened this issue Jul 7, 2023 · 1 comment · Fixed by #14179
Labels
F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Milestone

Comments

@EricLeeN1
Copy link

相关平台

支付宝小程序

小程序基础库: 2.8.10
使用框架: React

复现步骤

配置自定义tabbar,直接运行

经过查询源码这个位置
源码位置

const config: any = {
    [ATTACHED] () {
      perf.start(PAGE_INIT)
      const path = getPath(id, { id: this.getPageId?.() || pageId() })
      Current.app!.mount!(component, path, () => {
        componentElement = env.document.getElementById<TaroRootElement>(path)
        ensure(componentElement !== null, '没有找到组件实例。')
        this.$taroInstances = instances.get(path)
        safeExecute(path, ON_LOAD)
        if (!isWeb) {
          componentElement.ctx = this
          componentElement.performUpdate(true)
        }
      })
    },
    [DETACHED] () {
      const path = getPath(id, { id: this.getPageId() }) // 这里需要也加一个pageId() 
      Current.app!.unmount!(path, () => {
        instances.delete(path)
        if (componentElement) {
          componentElement.ctx = null
        }
      })
    },
    methods: {
      eh: eventHandler
    }
  }

期望结果

正常运行,渲染自定义tabbar

实际结果

报错:(index):1 TypeError: this.getPageId is not a function

环境信息

Taro v3.2.13


  Taro CLI 3.2.13 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
      npm: 6.10.0 - C:\Program Files\nodejs\node_global\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x labels Jul 7, 2023
@EricLeeN1
Copy link
Author

应该是支付宝小程序 自定义tabbar 没有this.getPageId()方法导致

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants