![](/img/trans.png)
[英]How to create a react project with specific version of create-react-app?
[英]Video tag on react with create-react-app project
我在将本地视频添加到我的项目时遇到问题
<video src={import(src/assets/abc.mp4)} type="video/mp4"/>
我已经研究发现
Web Pack配置
使之成为可能,但我不知道如何将其引入create-react-app项目。
我不能将视频托管在云中,因为我也需要移动版本的视频。任何人都可以帮忙吗?
您尝试使用的语法(动态import()
)用于代码拆分 ,而不是用于添加文件 。
我不确定您为什么要寻找Webpack配置,因为开箱即用的支持。
请遵循解释如何导入资产的官方文档 :
// Assuming abc.mp4 is in the same folder as this component
import myVideo from './abc.mp4';
// This will become a string with the path to the video at build time
// Your component definition
export default function MyComponent() {
return <video src={myVideo} type="video/mp4" />;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.