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

循环体内,自定义组件条件判断属性引用 item 值进行计算会出现问题 #6431

Closed
juanjiejie opened this issue May 21, 2020 · 0 comments · Fixed by #6565
Closed
Assignees

Comments

@juanjiejie
Copy link

juanjiejie commented May 21, 2020

问题描述

循环体内,同时使用自定义组件与条件判断语句时,控制台会报错:“item is not define”,渲染异常

复现步骤

type State = {
  list: any
}
export default class Test extends Component<{}, State> {
  config = {
    navigationBarTitleText: 'Test'
  }

  constructor (props, ...rest) {
    super(props, ...rest)
    this.state = {
      list: [
        {
          text: '1',
        },
        {
          text: '2'
        },
        {
          text: '3'
        },
        {
          text: '4'
        }
      ]
    }
  }

  render () {
    const { list } = this.state
    return (
        <View className='page'>
          {
            list.map((item) => {

              return <View>
                <View>{item.text}</View>
                {item.text==='1'&&<SoldOut />}
              </View>
            })
          }
        </View>
    )
  }
}

微信小程序以及H5正常,但是百度小程序控制台报错

期望行为

控制台不报错,可以正常渲染出组件

报错信息

image

系统信息

image
图片信息不知道为什么上传错误,taro和taro/cli版本都是2.2.6

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

Successfully merging a pull request may close this issue.

2 participants