upload_file.vue 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <el-upload
  3. class="upload-demo"
  4. action="/uapi/pub/upload"
  5. :data="{type:'freework_level'}"
  6. multiple
  7. :limit="3"
  8. :on-success="success"
  9. :file-list="fileList">
  10. <el-button size="small" type="primary">点击上传面试视频</el-button>
  11. </el-upload>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. fileList: [],
  18. id: 0,
  19. };
  20. },
  21. props: {//接收上级参数
  22. 'fileList':{
  23. type: Object,
  24. },
  25. 'id':{
  26. type: Number,
  27. }
  28. },
  29. methods: {
  30. success(e){
  31. //保存文件
  32. if(e.status!=1)
  33. {
  34. this.fileList=[];
  35. this.$message({
  36. message:"文件上传失败",
  37. type:"error"
  38. });
  39. }
  40. else
  41. {
  42. //保存文件
  43. this.$emit('click',this.id,e.data.url);
  44. }
  45. },
  46. }
  47. }
  48. </script>
  49. <style scoped>
  50. .upload-demo{display: inline-block}
  51. </style>