pdfvuer
pdfvuer copied to clipboard
[Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'pdfdata')"
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.