1、npm install flv.js

2、vue 文件引入,

import flvjs from 'flv.js'
  data() {
    return {
      player:null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.createVideo()
    })
  },

  beforeDestroy() {
    if (this.player) {
      this.player.pause()
      this.player.destroy()
      this.player = null
    }
  },
  methods: {
    createVideo() {
      const videoElement = this.$refs.videoElement // 定义播放路径
      if (flvjs.isSupported()) {
        this.player = flvjs.createPlayer({
          type: 'flv',
          url: '', // 你的url地址
          duration: 0,
          filesize: 0,
          enableStashBuffer: true,
          isLive: true, // 实时流
          hasAudio: false,
          hasVideo: true
        })
      } else {
        this.$message.error('不支持的格式')
        return
      }

      this.player.attachMediaElement(videoElement)
      this.player.load()
      this.player.play()
    }
  }