uploadFile.vue 915 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <div>
  3. <el-upload
  4. class="upload-demo"
  5. ref="upload"
  6. action=""
  7. :auto-upload="true"
  8. :on-change="upload"
  9. :http-request="uploadFile"
  10. :accept="accept"
  11. :limit="limit"
  12. >
  13. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  14. </el-upload>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. props:{
  20. accept: {
  21. type: String,
  22. default: ""
  23. },
  24. limit: {
  25. type: [String,Number],
  26. default: 1
  27. }
  28. },
  29. data(){ return {}},
  30. created(){},
  31. mounted(){},
  32. methods:{
  33. upload(file,fileList){
  34. console.log(file,fileList,'fileList')
  35. this.$emit("change",fileList)
  36. },
  37. uploadFile(file){
  38. console.log(file)
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss">
  44. </style>