export一个工厂模式的方法页面 报错:Uncaught ReferenceError: _TaroComponentClass is not defined
-
问题描述
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