App.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <uploader :options="options" :file-status-text="statusText" class="uploader-example" ref="uploader" @file-complete="fileComplete" @complete="complete"></uploader>
  3. </template>
  4. <script>
  5. export default {
  6. data () {
  7. return {
  8. options: {
  9. target: '//localhost:3000/upload', // '//jsonplaceholder.typicode.com/posts/',
  10. testChunks: false
  11. },
  12. attrs: {
  13. accept: 'image/*'
  14. },
  15. statusText: {
  16. success: '成功了',
  17. error: '出错了',
  18. uploading: '上传中',
  19. paused: '暂停中',
  20. waiting: '等待中'
  21. }
  22. }
  23. },
  24. methods: {
  25. complete () {
  26. debugger
  27. console.log('complete', arguments)
  28. },
  29. fileComplete () {
  30. console.log('file complete', arguments)
  31. }
  32. },
  33. mounted () {
  34. this.$nextTick(() => {
  35. window.uploader = this.$refs.uploader.uploader
  36. })
  37. }
  38. }
  39. </script>
  40. <style>
  41. .uploader-example {
  42. width: 880px;
  43. padding: 15px;
  44. margin: 40px auto 0;
  45. font-size: 12px;
  46. box-shadow: 0 0 10px rgba(0, 0, 0, .4);
  47. }
  48. .uploader-example .uploader-btn {
  49. margin-right: 4px;
  50. }
  51. .uploader-example .uploader-list {
  52. max-height: 440px;
  53. overflow: auto;
  54. overflow-x: hidden;
  55. overflow-y: auto;
  56. }
  57. </style>