首页 > 解决方案 > 如何在反应原生的webview中嵌入来自json数据的视频?

问题描述

大家好,我正在尝试在WebViewreact native 中嵌入视频。视频的 url 将从 json 响应中获取。但是当我像下面这样尝试时,我得到了这个错误

在此处输入图像描述

以下是我的代码

 fetch(GLOBAL.VIDEO_URL + this.props.navigation.state.params.id, {
                method: 'GET',
                headers: {
                    'Authorization': token
                }
            })
                .then((response) => response.json())
                .then((responseData) =>
                    this.setState({
                        section: responseData.data.video_url

                    })

                );

.....
....
 <View style={{ flex: 1, padding: 10 }}>

                        <WebView
                            source={{ uri: this.state.section }}
                            javaScriptEnabled={true}
                        />
                    </View>

json响应将如下

{
    "data": {
        "id": 8631,
        "post_title": "Video Unit 1",
        "post_content": "</p>\n",
        "vedio_url": [
            "xxxxxx"       ]
    }
}

请帮我找到解决方案。任何帮助都会非常重要。谢谢。

标签: react-nativewebviewvideo-streamingjsx

解决方案


推荐阅读