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

想要实现字符串拼接:

            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"
                },


发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量