1. 安装
npm install video.js --save
npm install videojs-contrib-hls --save
npm install @videojs/http-streaming --save
2. 按需引入
import videojs from 'video.js'
import 'videojs-contrib-hls'
import "@videojs/http-streaming"
3. 视频组件封装
<doc>
视频组件
</doc>
<template>
<video :id="id" style="width: 100%;height: 100%;" class="video-js vjs-default-skin" preload="auto">
<!-- <source src="rtsp://8.140.174.140:8045/s1" type="application/x-mpegURL"> -->
<source :src="videoUrl" type="application/x-mpegURL">
<!-- 勿删 -->
<!-- <source :src="url" :type="url.endsWith('m3u8')?'application/x-mpegURL':ur