| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <div>
- <file-pond
- ref="pond"
- name="file[]"
- label-idle="选择图片或拖动图片到此处"
- label-file-processing="图片正在上传,请稍后"
- label-file-processing-aborted="图片上传被取消"
- label-tap-to-retry="尝试重试"
- label-file-processing-complete="图片上传成功!"
- :allow-multiple="false"
- accepted-file-types="image/png, image/jpeg, image/jpg, image/gif"
- :server="server"
- :files="myFiles"
- :instant-upload="false"
- :image-edit-editor="editor"
- :image-edit-instant-edit="true"
- @init="handleFilePondInit"
- @processfile="success"
- />
- <!-- :instant-upload="false" 关闭立即上传到服务器 -->
- </div>
- </template>
- <script>
- // Import Vue FilePond
- import vueFilePond from 'vue-filepond'
- // Import FilePond styles
- import 'filepond/dist/filepond.min.css'
- // Import FilePond plugins
- // Please note that you need to install these plugins separately
- // Import image preview plugin styles
- import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css'
- import 'filepond-plugin-image-edit/dist/filepond-plugin-image-edit.css'
- // Import image preview and file type validation plugins
- import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type'
- import FilePondPluginImageEdit from 'filepond-plugin-image-edit'
- import FilePondPluginImagePreview from 'filepond-plugin-image-preview'
- import FilePondPluginImageExifOrientation from 'filepond-plugin-image-exif-orientation'
- import FilePondPluginFileValidateSize from 'filepond-plugin-file-validate-size'
- // Create component
- const FilePond = vueFilePond(
- FilePondPluginFileValidateType,
- FilePondPluginImagePreview,
- FilePondPluginImageExifOrientation,
- FilePondPluginFileValidateSize,
- FilePondPluginImageEdit
- )
- let videMessage = {}
- export default {
- name: 'FilePondUpdate',
- components: {
- FilePond
- },
- videMessage,
- data() {
- return {
- videMessage: {},
- myFiles: [],
- server: {
- url: '/api/file/upload/video',
- process: {
- headers: {
- 'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
- },
- onload(response) {
- // 返回上传数据
- videMessage = JSON.parse(response)
- }
- }
- },
- editor: {
- // Called by FilePond to edit the image
- // - should open your image editor
- // - receives file object and image edit instructions
- open: (file, instructions) => {
- // open editor here
- },
- // Callback set by FilePond
- // - should be called by the editor when user confirms editing
- // - should receive output object, resulting edit information
- onconfirm: (output) => {},
- // Callback set by FilePond
- // - should be called by the editor when user cancels editing
- oncancel: () => {},
- // Callback set by FilePond
- // - should be called by the editor when user closes the editor
- onclose: () => {}
- }
- }
- },
- created() {
- },
- methods: {
- handleFilePondInit() {
- // console.log('FilePond has initialized')
- // FilePond instance methods are available on `this.$refs.pond`
- },
- success() {
- this.$emit('photo', videMessage)
- }
- }
- }
- </script>
|