react使用video.js设置controls: true 依旧不显示控件,谁知道怎么解决
oyb81076
#2
我试了一下,没有任何毛病啊(用 create-react-app app --typescript)创建的项目
import React, { useRef, useEffect } from 'react';
import videojs from "video.js";
const App: React.FC = () => {
const ref = useRef<HTMLVideoElement | null>(null);
useEffect(() => {
videojs(ref.current, {
autoplay: "auto",
controls: true,
poster: "http://videojs.com/img/logo.png"
})
}, []);
return (
<video
ref={ref}
style={{ width: 800, height: 400 }}
controls={true}
>
<source src="http://vjs.zencdn.net/v/oceans.mp4" media="video/mp4" />
</video>
)
}
export default App;