0

我正在使用反应功能组件和 plyr-react 版本 3.2.1。

得到错误ref.current.plyr.on 不是函数

在 3.1.0 及以下版本中它工作正常

Stackblitz 链接 - https://stackblitz.com/edit/react-vv9haf

代码

const PlayerView = () => {
const ref = useRef();
 useEffect(() => {
  ref.current.plyr.on("ended", (event) => {
  console.log("ended-event");
 })
}, [])

 return (
 <Plyr
  id="player"
  options={{ ...options, controls }}
  source={src}
  ref={ref}
 />
);
4

1 回答 1

0

请尝试一下

ref?.current?.plyr?.on
于 2022-03-01T17:13:55.493 回答