我使用 React 作为前端。 我从 axios 调用中获取 mp4 视频文件:
const onGetVideo = () => {
axiosClient.get(`/solution/video.mp4`)
.then(({ data }) => {
console.log(data)
// data here is simple binary data
})
.catch(err => {
console.log(err)
})
}
如何使用响应(数据)在网站上显示视频?
您可以分享数据“响应”的格式吗
如果您的数据响应是这种格式,
数据 = [{video_url: ""}] 然后试试这个,
const video = data[0].video_url //(这里您的视频网址存储在视频变量中)
安装:npm安装react-player 在您的文件中添加此行: import ReactPlayer from 'react-player' 添加此代码:
尝试使用上面的代码。这应该可以解决你的问题
快乐编码!!