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

export一个工厂模式的方法页面 报错:Uncaught ReferenceError: _TaroComponentClass is not defined #4309

Closed
xinqiymsz opened this issue Aug 27, 2019 · 0 comments

Comments

@xinqiymsz
Copy link

问题描述
taro的公共页面使用工厂模式export出去之后发现这个错误:Uncaught ReferenceError: _TaroComponentClass is not defined
复现步骤
运行项目到此页面控制台报错

function CommonSelectPage (config) {
  const {
    title  //举例希望渲染不同的title
  } = config;
return class extends React.Component {
    constructor (props) {
      super(props)
      this.state = {
        list: []
      }
    }

  config = {
    navigationBarTitleText: '',
  }

  get checkedNum() {
    const { list } = this.state;
    return list.reduce((acc, cur) => acc = cur.status ? acc + 1 : acc, 0)
  }

  componentWillReceiveProps (nextProps) {
    console.log(this.props, nextProps);
  }

  render () {
    return (
      <View className='common-select'>
        {title} //举例希望渲染不同的title
      </View>
    )
  }
}
}

const commonSelectPage = new CommonSelectPage({title: 'lalala'});
export default commonSelectPage;

期望行为
此页面为公共页面 用config作为可配置的json 利用工厂模式 希望渲染出一个页面 只是一些字段不相同

报错信息

Uncaught ReferenceError: _TaroComponentClass is not defined

系统信息

  • Mac
  • Taro 版本 v.1.3.11
  • Node.js 版本v12.6.0
  • 报错平台 weapp
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

2 participants