在这里,我试图在vedios文件夹中的网页上播放视频。
我安装了npm我的样式组件
index.js:
import React from 'react';
import Vedio from "../../vedios/home_vedio.mp4";
import { HeroContainer, HeroBg, VedioBg } from './HeroElements';
const HeroSection = () => {
return (
<HeroContainer>
<HeroBg>
<VedioBg autoPlay loop muted src={Vedio} type = 'vedio/mp4' />
</HeroBg>
</HeroContainer>
)
}
export default HeroSection
HeroElements.js:
import styled from 'styled-components'
.....
.....
export const VedioBg = styled.vedio `
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
background: #232a34;
`
这是错误:
TypeError:styled_components__WEBPACK_IMPORTED_MODULE_0 __。default.vedio不是一个函数
我的导入部件有任何问题..!?
对于任何建议,我都是新手。
您在该行中使用了错误的标记:
export const VedioBg = styled.vedio `
无论您将来使用react
还是react-native
,它们都没有带有该名称的标签。这很可能只是拼写错误,使用video
标签是正确的
尝试这个:
const HeroSection = () => {
return (
<HeroContainer>
<HeroBg>
<VideoBg autoPlay loop muted src={Video} type = 'video/mp4' />
</HeroBg>
</HeroContainer>
)
}
export default HeroSection
import styled from 'styled-components'
.....
.....
export const VideoBg = styled.video `
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
background: #232a34;
`
PS我固定vedio
在video
任何地方,除了文件名。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句