NervJS / taro-ui

一款基于 Taro 框架开发的多端 UI 组件库
https://taro-ui.taro.zone
MIT License
4.55k stars 755 forks source link

AtTabs遍历AtTabsPane, AtTabsPane中再遍历数据某个list,第二层遍历中拿不到遍历的list #842

Open jianhao opened 5 years ago

jianhao commented 5 years ago

Taro UI 版本信息

2.2.2

问题描述

AtTabs遍历AtTabsPane, AtTabsPane中再遍历数据某个list,第二层遍历中拿不到遍历的list

复现步骤

复制官方代码,https://taro-ui.aotu.io/#/docs/tabs, 然后改成遍历AtTabsPane

复现代码

import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtTabs, AtTabsPane } from 'taro-ui'

export default class Index extends Taro.Component {
  constructor () {
    super(...arguments)
    this.state = {
      current: 0,
    }
  }
  handleClick (value) {
    this.setState({
      current: value
    })
  }
  render () {
    const tabList = [{ title: '标签页1' }, { title: '标签页2' }, { title: '标签页3' }]
    return (
      <AtTabs current={this.state.current} tabList={tabList} onClick={this.handleClick.bind(this)}>
        {
          tabList.map((tab, i) => {
            const list = ['苹果', '香蕉', '橘子']
            return (
              <AtTabsPane current={this.state.current} index={i} key={tab.title} >
                {
                  list.map((item) => {
                    console.log(list);
                    return (<View key={item}>{item}</View>)
                  })
                }
              </AtTabsPane>
            )
          })
        }
      </AtTabs>
    )
  }
}

报错信息

拿不到第二层遍历的list,很奇怪

系统信息

👽 Taro v1.3.18

Taro CLI 1.3.18 environment info: System: OS: macOS High Sierra 10.13.6 Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v10.15.3/bin/npm npmPackages: @tarojs/async-await: 1.3.18 => 1.3.18 @tarojs/components: 1.3.18 => 1.3.18 @tarojs/plugin-babel: 1.3.18 => 1.3.18 @tarojs/plugin-csso: 1.3.18 => 1.3.18 @tarojs/plugin-less: 1.3.18 => 1.3.18 @tarojs/plugin-sass: ^1.3.18 => 1.3.18 @tarojs/plugin-uglifyjs: 1.3.18 => 1.3.18 @tarojs/redux: 1.3.18 => 1.3.18 @tarojs/redux-h5: 1.3.18 => 1.3.18 @tarojs/router: 1.3.18 => 1.3.18 @tarojs/taro: 1.3.18 => 1.3.18 @tarojs/taro-alipay: 1.3.18 => 1.3.18 @tarojs/taro-h5: 1.3.18 => 1.3.18 @tarojs/taro-swan: 1.3.18 => 1.3.18 @tarojs/taro-tt: 1.3.18 => 1.3.18 @tarojs/taro-weapp: 1.3.18 => 1.3.18 @tarojs/webpack-runner: 1.3.18 => 1.3.18 eslint-config-taro: 1.3.18 => 1.3.18 eslint-plugin-taro: 1.3.18 => 1.3.18 nerv-devtools: ^1.4.0 => 1.4.4 nervjs: ^1.4.0 => 1.4.4 stylelint-config-taro-rn: 1.3.18 => 1.3.18 stylelint-taro-rn: 1.3.18 => 1.3.18

补充信息

taro-ui-bot[bot] commented 5 years ago

欢迎提交 Issue~

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

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

Good luck and happy coding~

yannanna0920 commented 4 years ago

我也遇到这个问题了 请问有解决办法了吗????

yannanna0920 commented 4 years ago

又试了一下AtTabsPane的 index 也要绑定current key绑定循环的id就好了