![](/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.