最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】ReactNative中字符串拼接

React Native crifan 7955浏览 0评论

想要实现字符串拼接:

            dataSource: ds.cloneWithRows([
                {
                    intentionLevel : "H",
                    customerName : "王小丫",
                    intentionCar : "奥迪A3进口",
                    updateTime : "2016/12/28"
                },
                            <Image style={styles.intentionLevel} source={require(‘./img/customerLevel_’ + {rowData.intentionLevel} + ‘.png’)} />

Images – React Native | A framework for building native apps using React

中,好像就是直接用加号+,去实现字符串拼接的。

不过是新建了变量了。

去改为:

<Image style={styles.intentionLevel} source={require(‘./img/customerLevel_’ + rowData.intentionLevel + ‘.png’)} />

就没有错误提示了。

【总结】

ReactNative中,字符串拼接,直接用+即可。

比如:

‘./img/customerLevel_’ + rowData.intentionLevel + ‘.png’

其中:

rowData.intentionLevel的值是’H’

对应着:

{
                    intentionLevel : "H",
                    customerName : "王小丫",
                    intentionCar : "奥迪A3进口",
                    updateTime : "2016/12/28"
                },

转载请注明:在路上 » 【已解决】ReactNative中字符串拼接

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.226 seconds, using 22.00MB memory