我无法将本地视频添加到我的项目
<video src={import(src/assets/abc.mp4)} type="video/mp4"/>
我研究过并发现了
网络包配置
使这成为可能,但我无法弄清楚如何将其引入create-react-app项目。
我无法为我的视频进行云托管,因为我也需要在移动版本上使用它。请问有人可以提供帮助吗?
答案 0 :(得分:5)
您尝试使用的语法(动态import()
)适用于code splitting,而不适用于adding files。
我不确定你为什么要寻找Webpack配置,因为这是开箱即用的。
请按照official documentation说明如何导入资产:
// 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" />;
}