We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题描述 列表渲染时,根据列表数组长度判断是否渲染情感图,运用三元运算符时,只能把代码写在里面,不能单独提取出来用函数执行吗?
[或者可以直接贴源代码,能贴文字就不要截图]
// 细节代码写在表达式里面是可以正常渲染的 render() { let len = this.state.addressList.length; return ( <View> { len ? <View className="address-list"> { this.state.addressList.map((item, index) => { return ( <View key={index} className="address-item"> <View className="hospital-name">{item.hospitalName}</View> <View className="hospital-info"> <Text>{item.administrative}</Text> <Text>{item.inpatient}</Text> <Text>{item.sickbed}</Text> </View> <View className="user-info"> <Text>{item.userName}</Text> <Text>{item.userMobile}</Text> </View> </View> ) }) } </View>: <View>123</View> } </View> ) } renderList = () => { return ( ) } renderEmpty = () => { return <View>123</View> }
// 细节代码用方法执行就渲染报错了 render() { let len = this.state.addressList.length; return ( <View className={ getIsIphoneX() ? 'page-wrapper page-addressManager IphoneX' : 'page-wrapper page-addressManager'}> { len ? this.renderList(): this.renderEmpty() } </View> ) } renderList = () => { return ( <View className="address-list"> { this.state.addressList.map((item, index) => { return ( <View key={index} className="address-item"> <View className="hospital-name">{item.hospitalName}</View> <View className="hospital-info"> <Text>{item.administrative}</Text> <Text>{item.inpatient}</Text> <Text>{item.sickbed}</Text> </View> <View className="user-info"> <Text>{item.userName}</Text> <Text>{item.userMobile}</Text> </View> </View> ) }) } </View> ) } renderEmpty = () => { return <View>123</View> }
期望行为 希望能支持函数渲染具体代码
报错信息
The text was updated successfully, but these errors were encountered:
有一条 eslint 的规则定义了这个行为: https://github.com/NervJS/taro/blob/master/packages/eslint-plugin-taro/docs/no-jsx-in-class-method.md
Sorry, something went wrong.
还是很赞了 比写原生小程序的语法好
Duplicate of #764
yuche
No branches or pull requests
问题描述
列表渲染时,根据列表数组长度判断是否渲染情感图,运用三元运算符时,只能把代码写在里面,不能单独提取出来用函数执行吗?
[或者可以直接贴源代码,能贴文字就不要截图]
期望行为
希望能支持函数渲染具体代码
报错信息
The text was updated successfully, but these errors were encountered: