-
Notifications
You must be signed in to change notification settings - Fork 19
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
Multiple page pdfs initiate multiple requests #10
Comments
Hi @shinchanZ , I think I'll have to make some changes on how the component functions. |
你的组件应该向上抽一层,用拿到的
|
my code: function getDocumentData(pdfPath: string): Promise<Uint8Array> {
return new Promise<Uint8Array>(function (resolve, reject) {
let xhr = new XMLHttpRequest();
xhr.open('GET', pdfPath);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
resolve(new Uint8Array(xhr.response));
};
xhr.onerror = function () {
reject(new Error('PDF is not loaded'));
};
xhr.send();
});
}
let state = reactive({
pdfDoc: null,
pdfPages: 0,
});
onMounted(async () => {
let docData = await getDocumentData(props.url);
const pdf = await createLoadingTask(docData).promise;
state.pdfDoc = docData;
state.pdfPages = pdf.numPages;
}); <template>
<VuePdf v-for="page in state.pdfPages" :key="page" :src="state.pdfDoc" :page="page+1" />
</template> |
It works,Thanks you very much! |
Hello, I have a question, why does my 20-page pdf initiate 20 requests, which will cause the loading to be very slow.
Thanks.
The text was updated successfully, but these errors were encountered: