Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'pdfdata')" #109

Open
Rombond opened this issue Nov 28, 2021 · 0 comments

Comments

@Rombond
Copy link

Rombond commented Nov 28, 2021

On vue 2 with pdfvuer, i got an error only if i use a v-for don't know why.
Error : [Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'pdfdata')"
Source code :

<template>
  <pdf :src="this.pdfdata" v-for="i in this.pdfnum" :key="i" :page="i">
    <template slot="loading">loading....</template>
  </pdf>
</template>

<script>
import PdfvuerVue from 'pdfvuer';

export default {
  components: {
        pdf: PdfvuerVue,
    },

    data: () => ({
        pdfnum: 0,
        pdfdata: null,
    }),

    mounted() {
        this.pdfdata = PdfvuerVue.createLoadingTask('./myPDF.pdf')
        this.pdfdata.then(pdf => {
            this.pdfnum = pdf.numPages;
        })
    },
</scritp>
<style>
</style>

If i change the template to this, it works perfectly :

<template>
  <pdf :src="this.pdfdata" :page="1">
    <template slot="loading">loading....</template>
  </pdf>
  <pdf :src="this.pdfdata" :page="2">
    <template slot="loading">loading....</template>
  </pdf>
</template>

I tried to put the v-for in a <div> but i doesn't change anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant