vue-upload-component icon indicating copy to clipboard operation
vue-upload-component copied to clipboard

Vue3 Support

Open maicolbruski opened this issue 5 years ago • 17 comments

Hello!

Do you have any idea to do with support for vue3? Tks!

maicolbruski avatar Sep 29 '20 14:09 maicolbruski

Why are you having issues with it with vue3?

heyaco avatar Oct 14 '20 04:10 heyaco

I've just tried using the simple demo from the example files in a vue3 project and it's got a problem with this.multiple in the maximum prop default

      maximum: {
        type: Number,
        default: function _default() {
          return this.multiple ? 0 : 1;
        }
      },
vue-upload-component.js?8019:740 Uncaught (in promise) TypeError: Cannot read property 'multiple' of undefined
    at _default (vue-upload-component.js?8019:740)

Looking at the vue3 migration guide:

Props default factory function no longer has access to this context

RichPC avatar Nov 17 '20 19:11 RichPC

I also waite for support for vue3. Thanks!

sergeynilov avatar Nov 22 '20 07:11 sergeynilov

I got this message too, and i want use upload zone component in vue 3. Anyone can help me?

vahidid avatar Nov 28 '20 18:11 vahidid

+1

andrefelipe avatar Nov 30 '20 15:11 andrefelipe

+1

mits87 avatar Nov 30 '20 20:11 mits87

Any progress?

mits87 avatar Dec 12 '20 17:12 mits87

Supported Vue3

npm install vue-upload-component@next --save

The first version 3.0, please try to be compatible

lian-yue avatar Dec 16 '20 23:12 lian-yue

Is there is some docs /example for Vue3 ? This https://lian-yue.github.io/vue-upload-component/#/documents seems for Vue2...

sergeynilov avatar Dec 18 '20 13:12 sergeynilov

Interface parameters are basically compatible with vue2 @sergeynilov

lian-yue avatar Dec 18 '20 18:12 lian-yue

@sergeynilov

<template>
    <div id="fs-upload-files">
        <FileUpload ref="upload" post-action="/url_post_upload" :multiple="true" v-model="files" class="btn btn-md btn-primary">Select files</FileUpload>
        <button @click.prevent="upload.active =  true">Upload</button>
        <ul>
            <li v-for="file of files" :key="file.id">
                {{file.id}} - {{file.name}} error:{{file.error}}
            </li>
        </ul>
</div>
</template>
<script lang="ts">
import {SetupContext, ref, Ref, defineComponent, watch} from "vue"
import FileUpload, {VueUploadItem} from 'vue-upload-component'

export default defineComponent({
  components: {
    FileUpload,
  },
  setup(props: any, context: SetupContext) {
    const upload = ref<any>(null)


    let files: Ref<VueUploadItem[]> = ref([])
    
    
    watch(upload, function(newUpload: any) {
      console.log("file", newUpload.files)
    })

    
    return {
      upload,
      files,
    }
  },
})
</script>

lian-yue avatar Dec 18 '20 18:12 lian-yue

@lian-yue hey you think it might be a good idea to add a prop to configure how often progress/speed updates? Right now it's hard coded for 500ms. It feels choppy when you upload using a fast connection (1Gbps+) and makes the loading bar animations jumpy.

heyaco avatar Dec 19 '20 05:12 heyaco

@starkana

transition: width 1s ease;

lian-yue avatar Dec 19 '20 12:12 lian-yue

@lian-yue i've got an error when using it with the new script setup rfc : vue-upload-component.js:832 Uncaught (in promise) TypeError: _this7.$parent.$forceUpdate is not a function at Proxy.<anonymous> (vue-upload-component.js:832)

<script lang="ts" setup>
import FileUpload, { VueUploadItem } from 'vue-upload-component'
import { ref, watch } from 'vue'
import type { Ref } from 'vue'

const upload = ref<any>(null)
let files: Ref<VueUploadItem> = ref([])

watch(upload, (newUpload) => {
  console.log(newUpload)
})

</script>

damienroche avatar May 27 '21 09:05 damienroche

@sergeynilov

<template>
    <div id="fs-upload-files">
        <FileUpload ref="upload" post-action="/url_post_upload" :multiple="true" v-model="files" class="btn btn-md btn-primary">Select files</FileUpload>
        <button @click.prevent="upload.active =  true">Upload</button>
        <ul>
            <li v-for="file of files" :key="file.id">
                {{file.id}} - {{file.name}} error:{{file.error}}
            </li>
        </ul>
</div>
</template>
<script lang="ts">
import {SetupContext, ref, Ref, defineComponent, watch} from "vue"
import FileUpload, {VueUploadItem} from 'vue-upload-component'

export default defineComponent({
  components: {
    FileUpload,
  },
  setup(props: any, context: SetupContext) {
    const upload = ref<any>(null)


    let files: Ref<VueUploadItem[]> = ref([])
    
    
    watch(upload, function(newUpload: any) {
      console.log("file", newUpload.files)
    })

    
    return {
      upload,
      files,
    }
  },
})
</script>

after hitting the same issue with FileUpload.vue:54 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'multiple') at _default (FileUpload.vue:54:1) and adding you provided example for vue3 I still can't resolve that error on my website. Is there any proper documentation including examples for the vue-upload-component running in vue3?

theSilverFisch avatar Jan 06 '23 14:01 theSilverFisch

@theSilverFisch

Vue3

npm install  vue-upload-component@next --save

example, vue3

git clone [email protected]:lian-yue/vue-upload-component.git
cd vue-upload-component
npm install
npm run dev

vue3 file https://github.com/lian-yue/vue-upload-component/blob/master/docs/views/examples/Typescript.vue https://github.com/lian-yue/vue-upload-component/blob/master/docs/views/examples/Simple.vue

lian-yue avatar Jan 06 '23 15:01 lian-yue

<file-upload ref="upload" :size="1024 * 1024 * 10" extensions="gif,jpg,jpeg,png,webp" accept="image/png,image/gif,image/jpeg,image/webp" post-action="https://digivive.com/api" :multiple="false" v-model="files" @input-filter="inputFilter" @input-file="inputFile">

In main.ts file i have register component as app.component('file-upload', VueUploadComponent) . but still getting error . Error is FileUpload.vue:54 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'multiple') at _default (FileUpload.vue:54:1) . @lian-yue

ashishrai8880 avatar Oct 30 '23 05:10 ashishrai8880