videoDialog.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- 视频播放弹窗 -->
  3. <el-dialog
  4. :title="title"
  5. :visible.sync="show"
  6. @close="closeVideoDialog"
  7. @open="openVideoDialog"
  8. class="course-video-dialog"
  9. center>
  10. <video controls :src="videoUrl" class="course-video-box" ref="myVideo"></video>
  11. <p v-if="footerText">{{footerText}}</p>
  12. </el-dialog>
  13. </template>
  14. <script>
  15. export default {
  16. name: "videoDialog",
  17. props: {
  18. source: {
  19. type: String,
  20. require: true
  21. },
  22. footerText: {
  23. type: String,
  24. },
  25. visible: {
  26. type: Boolean,
  27. require: true
  28. }
  29. },
  30. data() {
  31. return {
  32. title: '',
  33. show: false,
  34. videoUrl: '',
  35. }
  36. },
  37. watch: {
  38. visible: {
  39. handler(newVal) {
  40. this.show = newVal;
  41. },
  42. immediate: true
  43. }
  44. },
  45. methods: {
  46. openVideoDialog() {
  47. this.videoUrl = this.source;
  48. },
  49. closeVideoDialog() {
  50. this.$refs.myVideo.pause();
  51. this.$emit('update:visible',false);
  52. this.videoUrl = "";
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. </style>