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.triggerEvent is not a function #4098

Closed
nyrf opened this issue Aug 7, 2019 · 1 comment
Closed

组件调用父页面事件一直this.triggerEvent is not a function #4098

nyrf opened this issue Aug 7, 2019 · 1 comment

Comments

@nyrf
Copy link

nyrf commented Aug 7, 2019

问题描述
组件调用父页面事件一直this.triggerEvent is not a function,

复现步骤
[复现问题的步骤]

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error
// src/pages/index/demoPage.js
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import Demo from '../../components/demo/demo'
import './index.scss'

export default class DemoPage extends Component {
  state = {}
  config = {
    navigationBarTitleText: '首页'
  }
  closeBtn() {
    console.log('main close')
  }

  render() {
    return (
      <View className='index'>
        <Demo onCloseBtn={this.closeBtn} />
      </View>
    )
  }
}

// src/components/demo/demo.js
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'

export default class Demo extends Component {
  closeEvent() {
    console.log('close')
    this.triggerEvent('closeBtn')
  }
  render() {
    return <View onClick={this.closeEvent.bind(this)}>DEMO</View>
  }
}
// ```

报错信息

WX20190807-150442@2x

系统信息
👽 Taro v1.3.11

Taro CLI 1.3.11 environment info:
System:
OS: macOS 10.14.4
Shell: 3.0.2 - /usr/local/bin/fish
Binaries:
Node: 12.6.0 - ~/.config/nvm/12.6.0/bin/node
Yarn: 1.12.1 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.config/nvm/12.6.0/bin/npm

@taro-bot
Copy link

taro-bot bot commented Aug 7, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant