与 create-react-app 项目反应的视频标签
Video tag on react with create-react-app project
我在将本地视频添加到我的项目时遇到问题
<video src={import(src/assets/abc.mp4)} type="video/mp4"/>
我已经研究并发现了
web pack configuration
使这成为可能,但我不知道如何将它引入 create-react-app 项目。
我不能为我的视频进行云托管,因为我需要在移动版本上使用它,因为 well.please 谁能帮忙?
您尝试使用的语法(动态 import()
)适用于 code splitting, not for 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" />;
}
我在将本地视频添加到我的项目时遇到问题
<video src={import(src/assets/abc.mp4)} type="video/mp4"/>
我已经研究并发现了
web pack configuration
使这成为可能,但我不知道如何将它引入 create-react-app 项目。
我不能为我的视频进行云托管,因为我需要在移动版本上使用它,因为 well.please 谁能帮忙?
您尝试使用的语法(动态 import()
)适用于 code splitting, not for 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" />;
}