Image 反应本机映像错误失败的道具类型:提供给ForwardRef(映像)的道具源无效

Image 反应本机映像错误失败的道具类型:提供给ForwardRef(映像)的道具源无效,image,react-native,react-props,imagesource,Image,React Native,React Props,Imagesource,在我的react原生应用程序中,我有一个包含图像组件的组件数组,但我有这个错误 警告:失败的道具类型:提供给的道具源无效 ForwardRef(图像) 文件活动预览 render() { return ( <TouchableOpacity> <ImageBackground source={ require(this.props.imageFilePath) } >

在我的react原生应用程序中,我有一个包含图像组件的组件数组,但我有这个错误

警告:失败的道具类型:提供给的道具源无效 ForwardRef(图像)

文件活动预览

render() {
    return (
        <TouchableOpacity>
            <ImageBackground
                source={ require(this.props.imageFilePath) }
            >
            </ImageBackground>
        </TouchableOpacity>
    );
}
render(){
返回(
);
}
归档回家

render() {
    let campaigns = [
        {
            id: 1,
            name: "WildFit",
            expire: 1868029014,
            picFrame: "../assets/picture.jpg",
            done: 0.75
        }
    ];

    let campaignViews = campaigns.map( c => {
        return (
            <CampaignPreview
                imageFilePath={ c.picFrame }
                name={ c.name }
                completation={ c.done }
                key={ c.id }
            />              
        );
    });

    let view = (
        <View>
            <ScrollView>
                { campaignViews }
            </ScrollView>
        </View>
        );

    return view;
}
render(){
让活动=[
{
id:1,
名称:“WildFit”,
到期日期:1868029014,
picFrame:“../assets/picture.jpg”,
完成:0.75
}
];
让活动视图=活动.map(c=>{
返回(
);
});
让视图=(
{活动视图}
);
返回视图;
}
但是,如果我将字符串而不是
this.props.imageFilePath
放进去,它会工作

我似乎不可能在react native中使用“require(var)”,我永远使用require('location'),您可以尝试将字符串保存在变量中

只需要接受文本的字符串

我似乎在react native中不可能使用“require(var)”,我一直使用require(“location”),您可以尝试将字符串保存在变量中

只需要接受文本的字符串