react-native - 如何在反应原生的webview中嵌入来自json数据的视频?
问题描述
大家好,我正在尝试在WebView
react 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" ]
}
}
请帮我找到解决方案。任何帮助都会非常重要。谢谢。
解决方案
推荐阅读
- c - malloc 函数内存分配大小问题
- python - Kaggle 的“SQL 简介”课程中设置了 max_results 值和 to_dataframe 的 list_rows 问题
- javascript - 如何在 React 中设置动态环境配置
- docker - 在 Docker Swarm 中使用模板占位符来绑定卷
- javascript - 无法在 discord.js 上的 channels.get() 内放置变量
- javascript - 如果加载了主页组件,如何直接进入登录页面
- android - android:应用程序被杀死后,后退按钮从工具栏中消失
- apache-flink - Flink 检查点大小正在增长超过 20GB,检查点时间超过 1 分钟
- c# - c#中列表中的对数和最大值
- java - Java - 可以创建一个可以存储任何子类实例的父类对象吗?