taro icon indicating copy to clipboard operation
taro copied to clipboard

子组件的 props 传参问题,子组件获取到了一些没有以 props 传递给它的数据

Open Dithub2016 opened this issue 8 years ago • 0 comments

问题描述 没有给子组件传递某个参数,它却自动获取到了。。。

复现步骤

      {shoppingCart.specs.map(item => (
            <View className="" key={item.id}>
              <View className=''>
                <ProductIntro
                  image={item.image}
                  title={item.title}
                  spec={item.name}
                  price={item.price}
                />
              </View>
            </View>
          ))}

// shoppingCart.specs 长这样
shoppingCart.specs = [{
       id: null, goods_id: null,
        name: null, image: null,
        title: null,
        price: null,
        orig_price: null,
        stock: null,
        count: 0,
}]
// 然后 `ProductIntro` 组件可以接收一个 `props` 为 count ,但在这里并没有传递给它,它却拿到了

期望行为 bug 修复

报错信息 image 上面的 count 为 2,就是问题所在,感觉这样把整个数据丢进去的做法,重名率好高啊

系统信息

  • 操作系统: win7
  • Taro 版本 v0.0.69
  • Node.js 版本 v8.11.2

Dithub2016 avatar Jul 12 '18 03:07 Dithub2016