1
votes

My component looks like below.

<template>
            <uploader class="uploader-example">
                <uploader-unsupport></uploader-unsupport>
                <uploader-drop>
                    <p>Drop files here to upload or</p>
                    <uploader-btn>select files</uploader-btn>
                    <uploader-btn :directory="true">select folder</uploader-btn>
                </uploader-drop>
                <uploader-list></uploader-list>
            </uploader>

</template>

<script lang="ts">
    import { Component, Vue } from 'vue-property-decorator';
    import uploader from 'vue-simple-uploader';
    @Component({
        components: {
            Uploader: uploader,
        },
    })
    export default class In extends Vue {

    }
</script>

My shims-vue.d.ts file looks like below:

declare module '*.vue' {
  import Vue from 'vue';
  export default Vue;
}

declare module 'vue-simple-uploader';

With above code I am getting below error:

[Vue warn]: Failed to mount component: template or render function not defined.

and also uploader component is not being rendered.

I have used below package.

https://github.com/simple-uploader/vue-uploader

2

2 Answers

2
votes

You're binding the library incorrectly — it's written as a Vue plugin, not as a standalone component.

The correct usage is outlined in the project readme:

// main.ts
import Vue from 'vue'
import uploader from 'vue-simple-uploader'

Vue.use(uploader)

No further import as a subcomponent is necessary, as it's registered globally. This isn't good practice, but it's how the component is written.

1
votes

you forgot to init the uploader in the main app.js file :

import Vue from 'vue'
import uploader from 'vue-simple-uploader'
import App from './App.vue'

Vue.use(uploader)

or try this :

@Component({
    components: {
        uploader: uploader,
    },
})