首页 > 其他分享 >Vue上传视频组件

Vue上传视频组件

时间:2023-11-28 11:04:47浏览次数:29  
标签:Vue fileList video file 组件 message 上传 response

整合上传组件

<el-form-item label="上传视频">
    <el-upload
           :on-success="handleVodUploadSuccess"
           :on-remove="handleVodRemove"
           :before-remove="beforeVodRemove"
           :on-exceed="handleUploadExceed"
           :file-list="fileList"
           :action="BASE_API+'/admin/vod/video/upload'"
           :limit="1"
           class="upload-demo">
    <el-button size="small" type="primary">上传视频</el-button>
    <el-tooltip placement="right-end">
        <div slot="content">最大支持1G,<br>
            支持3GP、ASF、AVI、DAT、DV、FLV、F4V、<br>
            GIF、M2T、M4V、MJ2、MJPEG、MKV、MOV、MP4、<br>
            MPE、MPG、MPEG、MTS、OGG、QT、RM、RMVB、<br>
            SWF、TS、VOB、WMV、WEBM 等视频格式上传</div>
        <i class="el-icon-question"/>
    </el-tooltip>
    </el-upload>
</el-form-item>

方法定义

import vod from '@/api/edu/vod'
//数据定义
//写核心代码的位置
export default {
  data() {
    return {
     fileList: [],//上传文件列表
     BASE_API: process.env.BASE_API ,// 接口API地址
     video: {// 课时对象
     title: '',
     sort: 0,
     free: false,
     videoSourceId: '',
     videoOriginalName: ''
},
    };
  },
  created() {//渲染前执行

  },
  watch: {

  },
  methods: {
   //成功回调
  handleVodUploadSuccess(response, file, fileList) {
    this.video.videoSourceId = response.data.videoId
    this.video.videoOriginalName = file.name;
},
//修改回掉
editVideo(videoId) {
    this.dialogVideoFormVisible = true
        video.getVideoInfoById(videoId).then(response => {
        this.video = response.data.item
        this.fileList = [{'name': this.video.videoOriginalName}]
    })
},
//视图上传多于一个视频
  handleUploadExceed(files, fileList) {
  this.$message.warning('想要重新上传视频,请先删除已上传的视频')
}, beforeVodRemove(file, fileList) {
  return this.$confirm(`确定移除 ${file.name}?`)
},
handleVodRemove(file, fileList) {
  console.log(file)
  vod.removeById(this.video.videoSourceId).then(response=>{
    this.$message({
      type: 'success',
      message: response.message
    })
  })
},
   handleVodRemove(file, fileList) {
    console.log(file)
    vod.removeById(this.video.videoSourceId).then(response => {
        this.video.videoSourceId = ''
        this.video.videoOriginalName = ''
        this.fileList = []
        this.$message({
            type: 'success',
            message: response.message
        })
    })
},




  }

};

参考文章:http://blog.ncmem.com/wordpress/2023/11/03/vue上传视频组件/


 

 

标签:Vue,fileList,video,file,组件,message,上传,response
From: https://blog.51cto.com/u_14023400/8597124

相关文章

  • vue 视频上传组件
    组件:<template><divclass="upload-box"><divclass="avatar-uploader-box"><!--图片预览--><div:key="index"class="video-preview"v-for="(item,index)invideoList"......
  • vue图片上传视频
    图片上传是现在Web开发中常见的需求之一。而使用Vue框架可以使得这一过程更加方便和有效。在Vue中使用预先开发好的组件,可以快速地实现图片上传功能。//在Vue组件中引用插件importVueUploadComponentfrom'vue-upload-component'//在模板中引用组件上面的代码使用VueUpload......
  • vue上传视频框架
    在Web应用程序中经常需要用户上传视频,以便内容分享,教程和其他目的。Vue.js是一种流行的JavaScript框架,它提供了一种方便的方式来设计交互式和动态的用户界面,因此Vue上传视频框架是一种非常受欢迎的技术。Vue.js框架提供了各种插件和工具,它们可以帮助开发人员轻松地实现视频上传功能......
  • 使用 CKEditor 上传图片, 粘贴屏幕截图
    之前写过wangEditor,那真是好用,文档也清晰,半天就搞定了,无奈没有对应license,只好选择别的。外语一般,阅读理解都靠蒙。CKEditor官方文档看的我云里雾里,国内的博客比较少,经过一天的调试,终于成功了。记录下,欢迎交流。1.下载CKEditor包。 打开samples文件夹下的index.html,确认ckedi......
  • PHP大文件分割上传详解
    这篇文章主要为大家详细介绍了PHP大文件分割上传,PHP分片上传,具有一定的参考价值,感兴趣的小伙伴们可以参考一下服务端为什么不能直接传大文件?跟php.ini里面的几个配置有关upload_max_filesize=2M//PHP最大能接受的文件大小post_max_size=8M//PHP能收到的最大POST值'memory_l......
  • CKEDITOR图片上传实现详细步骤
    CKEditor的编辑器工具栏中有一项“图片域”,该工具可以贴上图片地址来在文本编辑器中加入图片,但是没有图片上传。  “预览”中有一大堆鸟语,看得很不爽。可以打开ckeditor/plugins/image/dialogs/image.js文件,搜索“b.config.image_previewText”就能找到这段鸟语了,(b.config.image......
  • Vue3 + [email protected] + UploadPictureCard
    <template><a-uploadname="file"v-model:file-list="showFileList"list-type="picture-card":multiple="multiple":max-count="maxCount":before-up......
  • 界面控件DevExpress WPF流程图组件,完美复制Visio UI!(二)
    DevExpressWPFDiagram(流程图)控件帮助用户完美复制MicrosoftVisioUI,并将信息丰富且组织良好的图表、流程图和组织图轻松合并到您的下一个WPF项目中。在上文中(点击这里回顾>>),我们为大家介绍了DevExpressWPFDiagram(流程图)组件性能优异切信息丰富的流程图功能、轻松地从数据源......
  • vue引入外部样式只在当前文件生效
    引入外部文件时,想要只在当前组件使用,但是我们使用如下方式时,会在全局使用。因为在scoped起作用的时候,import还没有引入这个文件<stylescoped>@import"../../xx.css"</style>使用以下方式即可<stylescopedsrc="../../xx.css"></style> ......
  • 【源码系列#02】Vue3响应式原理(Effect)
    专栏分享:vue2源码专栏,vue3源码专栏,vuerouter源码专栏,玩具项目专栏,硬核......