Ase*_*ela 1 javascript reactjs create-react-app
我在向项目添加本地视频时遇到问题
<video src={import(src/assets/abc.mp4)} type="video/mp4"/>
Run Code Online (Sandbox Code Playgroud)
我研究过并发现了
网络包配置
使这成为可能但我无法弄清楚如何将它介绍到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" />;
}
Run Code Online (Sandbox Code Playgroud)