You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Uploader.vue 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div id="page">
  3. <header>
  4. <h1 class="logo"><a href="http://www.helloweba.net" title="返回helloweba首页">helloweba</a></h1>
  5. </header>
  6. <div class="main">
  7. <h2><a href="http://www.helloweba.net/javascript/632.html">使用vue-simple-uploader上传文件和文件夹</a></h2>
  8. <p style="text-align:center;color: #999">温馨提示:可将文件拖动到灰色区域上传</p>
  9. <uploader :options="options" :fileStatusText="fileStatusText" class="uploader">
  10. <uploader-unsupport></uploader-unsupport>
  11. <uploader-drop>
  12. <uploader-btn class="upfile"><i class="iconfont icon-upload"></i> 上传文件</uploader-btn>
  13. <uploader-btn class="updir" :directory="true"><i class="iconfont icon-dir"></i> 上传文件夹</uploader-btn>
  14. </uploader-drop>
  15. <uploader-list></uploader-list>
  16. </uploader>
  17. </div>
  18. <footer>
  19. <p>Powered by helloweba.net 允许转载、修改和使用本站的DEMO,但请注明出处:<a href="http://www.helloweba.net">www.helloweba.net</a></p>
  20. <p class="hidden"></p>
  21. </footer>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. data () {
  27. return {
  28. options: {
  29. target: 'uploader.php',
  30. testChunks: false,
  31. chunkSize: 1024*1024*128, //128MB
  32. simultaneousUploads: 1, //并发上传数
  33. headers: {
  34. 'X-token': 'abcd123'
  35. },
  36. maxChunkRetries: 3, //最大自动失败重试上传次数
  37. },
  38. fileStatusText: {
  39. success: '上传成功',
  40. error: '上传出错了',
  41. uploading: '上传中...',
  42. paused: '暂停',
  43. waiting: '等待中...'
  44. },
  45. attrs: {
  46. accept: 'image/*'
  47. }
  48. }
  49. },
  50. // mounted () {
  51. // this.$nextTick(() => {
  52. // window.uploader = this.$refs.uploader.uploader
  53. // })
  54. // }
  55. }
  56. </script>
  57. <style scoped lang="less">
  58. .main{
  59. max-width: 1000px;
  60. margin: 10px auto;
  61. background: #fff;
  62. padding: 10px;
  63. h2{
  64. padding: 30px 0;
  65. text-align: center;
  66. font-size: 20px;
  67. }
  68. }
  69. .uploader {
  70. width: 880px;
  71. padding: 15px;
  72. margin: 20px auto 0;
  73. font-size: 14px;
  74. box-shadow: 0 0 10px rgba(0, 0, 0, .4);
  75. .uploader-btn {
  76. margin-right: 4px;
  77. color: #fff;
  78. padding: 6px 16px;
  79. }
  80. .upfile{
  81. border: 1px solid #409eff;
  82. background: #409eff;
  83. }
  84. .updir{
  85. border: 1px solid #67c23a;
  86. background: #67c23a;
  87. }
  88. .uploader-list {
  89. max-height: 440px;
  90. overflow: auto;
  91. overflow-x: hidden;
  92. overflow-y: auto;
  93. }
  94. // /deep/.uploader-drop{
  95. // height: 400px;
  96. // }
  97. }
  98. //手机等小屏幕手持设备。当设备宽度 在 320px和768px之间时,执行当前的css
  99. @media only screen and (min-width: 320px) and (max-width: 768px) {
  100. .uploader {
  101. width: 98%;
  102. padding: 0;
  103. box-shadow: none;
  104. }
  105. }
  106. </style>