小编Jus*_*cia的帖子

video.js 版本 8.XX 类型、TypeScript React 和插件 [2023]

问题:

背景:我正在移植带有 video.js 和插件的 jQuery 应用程序。到 TypeScript React 应用程序。

尝试将 video.js 当前版本 8.3.0 与 TypeScript 和第 3 方插件一起使用会导致类型错误,例如:Property 'playlist' does not exist on type 'Player'

简化示例

应该注意的是,这个设置实际上可以在生产环境中使用多个插件,但是 TS 服务器会抛出错误。


import { useRef } from 'react';
import videojs from 'video.js';
import type Player from 'video.js/dist/types/player';
import 'videojs-playlist';

const videoElement = document.createElement('video-js');
const playerRef = useRef<Player | null>(null);
const playlist = [{...}];
const options = {...};

const player = (playerRef.current = videojs(videoElement, options));

player.autoplay(false);
player.playlist(playlist); // TS Error: Property …
Run Code Online (Sandbox Code Playgroud)

plugins video.js typescript reactjs

5
推荐指数
0
解决办法
8385
查看次数

标签 统计

plugins ×1

reactjs ×1

typescript ×1

video.js ×1