方诺官网改正版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

282 lines
11 KiB

  1. <template>
  2. <div>
  3. <div class="intro-y flex items-center mt-8">
  4. <h2 class="text-lg font-medium mr-auto">Dropzone</h2>
  5. </div>
  6. <div class="grid grid-cols-12 gap-6 mt-5">
  7. <div class="intro-y col-span-12 lg:col-span-6">
  8. <!-- BEGIN: Single File Upload -->
  9. <div class="intro-y box">
  10. <div
  11. class="flex flex-col sm:flex-row items-center p-5 border-b border-gray-200 dark:border-dark-5"
  12. >
  13. <h2 class="font-medium text-base mr-auto">Single File Upload</h2>
  14. <div
  15. class="w-full sm:w-auto flex items-center sm:ml-auto mt-3 sm:mt-0"
  16. >
  17. <div class="mr-3">Show example code</div>
  18. <input
  19. data-target="#single-file-upload"
  20. class="show-code input input--switch border"
  21. type="checkbox"
  22. />
  23. </div>
  24. </div>
  25. <div id="single-file-upload" class="p-5">
  26. <div class="preview">
  27. <VueDropzone
  28. id="dropzone-single"
  29. :use-custom-slot="true"
  30. :options="{
  31. url: 'https://httpbin.org/post',
  32. thumbnailWidth: 150,
  33. maxFilesize: 0.5,
  34. maxFiles: 1,
  35. headers: { 'My-Awesome-Header': 'header value' }
  36. }"
  37. class="dropzone border-gray-200 border-dashed text-gray-800 hover:bg-transparent"
  38. >
  39. <div class="text-lg font-medium">
  40. Drop files here or click to upload.
  41. </div>
  42. <div class="text-gray-600">
  43. This is just a demo dropzone. Selected files are
  44. <span class="font-medium">not</span> actually uploaded.
  45. </div>
  46. </VueDropzone>
  47. </div>
  48. <div class="source-code hidden">
  49. <button
  50. data-target="#copy-single-file-upload"
  51. class="copy-code button button--sm border flex items-center text-gray-700 dark:border-dark-5 dark:text-gray-300"
  52. >
  53. <FileIcon class="w-4 h-4 mr-2" /> Copy example code
  54. </button>
  55. <div class="overflow-y-auto h-64 mt-3">
  56. <Highlight id="copy-single-file-upload" class="source-preview">
  57. <code
  58. class="text-xs p-0 rounded-md html pl-5 pt-8 pb-4 -mb-10 -mt-10"
  59. >
  60. <textarea>
  61. <VueDropzone
  62. id="dropzone-single"
  63. :use-custom-slot="true"
  64. :options="{
  65. url: 'https://httpbin.org/post',
  66. thumbnailWidth: 150,
  67. maxFilesize: 0.5,
  68. maxFiles: 1,
  69. headers: { 'My-Awesome-Header': 'header value' }
  70. }"
  71. class="dropzone border-gray-200 border-dashed text-gray-800 hover:bg-transparent"
  72. >
  73. <div class="text-lg font-medium">
  74. Drop files here or click to upload.
  75. </div>
  76. <div class="text-gray-600">
  77. This is just a demo dropzone. Selected files are
  78. <span class="font-medium">not</span> actually uploaded.
  79. </div>
  80. </VueDropzone>
  81. </textarea>
  82. </code>
  83. </Highlight>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <!-- END: Single File Upload -->
  89. <!-- BEGIN: Multiple File Upload -->
  90. <div class="intro-y box mt-5">
  91. <div
  92. class="flex flex-col sm:flex-row items-center p-5 border-b border-gray-200 dark:border-dark-5"
  93. >
  94. <h2 class="font-medium text-base mr-auto">Multiple File Upload</h2>
  95. <div
  96. class="w-full sm:w-auto flex items-center sm:ml-auto mt-3 sm:mt-0"
  97. >
  98. <div class="mr-3">Show example code</div>
  99. <input
  100. data-target="#multiple-file-upload"
  101. class="show-code input input--switch border"
  102. type="checkbox"
  103. />
  104. </div>
  105. </div>
  106. <div id="multiple-file-upload" class="p-5">
  107. <div class="preview">
  108. <VueDropzone
  109. id="dropzone-multiple"
  110. :use-custom-slot="true"
  111. :options="{
  112. url: 'https://httpbin.org/post',
  113. thumbnailWidth: 150,
  114. maxFilesize: 0.5,
  115. headers: { 'My-Awesome-Header': 'header value' }
  116. }"
  117. class="dropzone border-gray-200 border-dashed text-gray-800 hover:bg-transparent"
  118. >
  119. <div class="text-lg font-medium">
  120. Drop files here or click to upload.
  121. </div>
  122. <div class="text-gray-600">
  123. This is just a demo dropzone. Selected files are
  124. <span class="font-medium">not</span> actually uploaded.
  125. </div>
  126. </VueDropzone>
  127. </div>
  128. <div class="source-code hidden">
  129. <button
  130. data-target="#copy-multiple-file-upload"
  131. class="copy-code button button--sm border flex items-center text-gray-700 dark:border-dark-5 dark:text-gray-300"
  132. >
  133. <FileIcon class="w-4 h-4 mr-2" /> Copy example code
  134. </button>
  135. <div class="overflow-y-auto h-64 mt-3">
  136. <Highlight
  137. id="copy-multiple-file-upload"
  138. class="source-preview"
  139. >
  140. <code
  141. class="text-xs p-0 rounded-md html pl-5 pt-8 pb-4 -mb-10 -mt-10"
  142. >
  143. <textarea>
  144. <VueDropzone
  145. id="dropzone-multiple"
  146. :use-custom-slot="true"
  147. :options="{
  148. url: 'https://httpbin.org/post',
  149. thumbnailWidth: 150,
  150. maxFilesize: 0.5,
  151. headers: { 'My-Awesome-Header': 'header value' }
  152. }"
  153. class="dropzone border-gray-200 border-dashed text-gray-800 hover:bg-transparent"
  154. >
  155. <div class="text-lg font-medium">
  156. Drop files here or click to upload.
  157. </div>
  158. <div class="text-gray-600">
  159. This is just a demo dropzone. Selected files are
  160. <span class="font-medium">not</span> actually uploaded.
  161. </div>
  162. </VueDropzone>
  163. </textarea>
  164. </code>
  165. </Highlight>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. <!-- END: Multiple File Upload -->
  171. </div>
  172. <div class="intro-y col-span-12 lg:col-span-6">
  173. <!-- BEGIN: File Type Validation -->
  174. <div class="intro-y box">
  175. <div
  176. class="flex flex-col sm:flex-row items-center p-5 border-b border-gray-200 dark:border-dark-5"
  177. >
  178. <h2 class="font-medium text-base mr-auto">File Type Validation</h2>
  179. <div
  180. class="w-full sm:w-auto flex items-center sm:ml-auto mt-3 sm:mt-0"
  181. >
  182. <div class="mr-3">Show example code</div>
  183. <input
  184. data-target="#file-type-validation"
  185. class="show-code input input--switch border"
  186. type="checkbox"
  187. />
  188. </div>
  189. </div>
  190. <div id="file-type-validation" class="p-5">
  191. <div class="preview">
  192. <VueDropzone
  193. id="dropzone-validation"
  194. :use-custom-slot="true"
  195. :options="{
  196. url: 'https://httpbin.org/post',
  197. thumbnailWidth: 150,
  198. maxFilesize: 0.5,
  199. acceptedFiles: 'image/jpeg|image/png|image/jpg',
  200. headers: { 'My-Awesome-Header': 'header value' }
  201. }"
  202. class="dropzone border-gray-200 border-dashed text-gray-800 hover:bg-transparent"
  203. @vdropzone-error="dropzoneError"
  204. >
  205. <div class="text-lg font-medium">
  206. Drop files here or click to upload.
  207. </div>
  208. <div class="text-gray-600">
  209. This is just a demo dropzone. Selected files are
  210. <span class="font-medium">not</span> actually uploaded.
  211. </div>
  212. </VueDropzone>
  213. </div>
  214. <div class="source-code hidden">
  215. <button
  216. data-target="#copy-file-type-validation"
  217. class="copy-code button button--sm border flex items-center text-gray-700 dark:border-dark-5 dark:text-gray-300"
  218. >
  219. <FileIcon class="w-4 h-4 mr-2" /> Copy example code
  220. </button>
  221. <div class="overflow-y-auto h-64 mt-3">
  222. <Highlight
  223. id="copy-file-type-validation"
  224. class="source-preview"
  225. >
  226. <code
  227. class="text-xs p-0 rounded-md html pl-5 pt-8 pb-4 -mb-10 -mt-10"
  228. >
  229. <textarea>
  230. <VueDropzone
  231. id="dropzone-validation"
  232. :use-custom-slot="true"
  233. :options="{
  234. url: 'https://httpbin.org/post',
  235. thumbnailWidth: 150,
  236. maxFilesize: 0.5,
  237. acceptedFiles: 'image/jpeg|image/png|image/jpg',
  238. headers: { 'My-Awesome-Header': 'header value' }
  239. }"
  240. @vdropzone-error="dropzoneError"
  241. class="dropzone border-gray-200 border-dashed text-gray-800 hover:bg-transparent"
  242. >
  243. <div class="text-lg font-medium">
  244. Drop files here or click to upload.
  245. </div>
  246. <div class="text-gray-600">
  247. This is just a demo dropzone. Selected files are
  248. <span class="font-medium">not</span> actually uploaded.
  249. </div>
  250. </VueDropzone>
  251. </textarea>
  252. </code>
  253. </Highlight>
  254. </div>
  255. </div>
  256. </div>
  257. </div>
  258. <!-- END: File Type Validation -->
  259. </div>
  260. </div>
  261. </div>
  262. </template>
  263. <script>
  264. import vue2Dropzone from "vue2-dropzone";
  265. export default {
  266. components: {
  267. VueDropzone: vue2Dropzone
  268. },
  269. methods: {
  270. dropzoneError(err) {
  271. if (
  272. "image/jpeg|image/png|image/jpg".split("|").indexOf(err.type) === -1
  273. ) {
  274. alert("Error! Files of this type are not accepted");
  275. }
  276. }
  277. }
  278. };
  279. </script>