Taro: 在map循环中,import进来的本地图片无法显示。

Created on 13 Jul 2018  ·  4Comments  ·  Source: NervJS/taro

问题描述
小程序环境下。
引入图片时,如果在map循环中,则import进来的本地图片无法显示,渲染结果src=""。
如果将代码移出map循环,图片可正常显示。

例如:


import noticeBackground from "./[email protected]";

export class Notice extends Component {
  render() {
    return (
      <Swiper className='notice-swiper' autoplay vertical circular>
        {
          [1,2,3].map((item, index) => (
            <SwiperItem className='notice-swiper-item' key={index}>
              <View className='notice'>
                <Image className='background' src={noticeBackground} />
              </View>
            </SwiperItem>
          ))
        }
      </Swiper>
    )
  }
}

系统信息

  • 操作系统: mac
  • Taro 版本 v.0.0.69
  • Node.js 版本 v9.11.1
bug

Most helpful comment

那暂时使用网络图片吧。

现在循环中只能使用 class 作用域的变量,目前的版本不打算修复这个问题了,v0.1.0 会对组件化进行重构,循环的逻辑会简单很多。应该本周应该能出来。

All 4 comments

请问换一张网络的图片可以吗

@yuche 用网络图片可以正常显示。

那暂时使用网络图片吧。

现在循环中只能使用 class 作用域的变量,目前的版本不打算修复这个问题了,v0.1.0 会对组件化进行重构,循环的逻辑会简单很多。应该本周应该能出来。

最新的 beta 版本已经修复此问题~

Was this page helpful?
0 / 5 - 0 ratings