GithubHelp home page GithubHelp logo

Comments (8)

NanyThery avatar NanyThery commented on June 14, 2024 1

Hello again!

I could finally manage it to work.

1) Component not registered. It seems there was an issue with the packages. Cannot tell which exactly. But it was just ignoring it. So I solved that issue by doing:
npm install
npm audit fix

On the other hand, and not directly related with this issue:

  1. I wanted the pdf download to start as soon as the URL loaded, so I put the generatePDF() function within the mounted() hook. This resulted in an error because the child components were not ready. So I had to implement the $nextTick() function.
    So, if anyone wants to download a PDF on mounted, yo need to do something like this:
  async fetch() {
    this.activeMenu = this.$store.state.activeMenu
  },
  mounted() {
    this.$nextTick(() => this.print())
  },

  methods: {
    print() {
      this.$refs.html2Pdf.generatePdf()
    },
  },

More doc on this:

What is next Tick

Maybe it could help to put also this use case in the docs for newbies like me. hehe.

Issue solved :D
Thanks again for your support.

Regards,

from vue-html2pdf.

kempsteven avatar kempsteven commented on June 14, 2024

Hmm can I see your file in this directory: ~/plugins/vue-html2pdf.js?

It should look like this:

// vue-html2pdf.js
import Vue from 'vue'
import VueHtml2pdf from 'vue-html2pdf'
Vue.use(VueHtml2pdf)

from vue-html2pdf.

NanyThery avatar NanyThery commented on June 14, 2024

Hi! Thanks for your reply,

Yes, this is what I have in my plugin file:

import Vue from 'vue'
import VueHtml2pdf from 'vue-html2pdf'

Vue.use(VueHtml2pdf)

Also tried with import * as VueHtml2pdf, but no results

image

from vue-html2pdf.

kempsteven avatar kempsteven commented on June 14, 2024

Weird, the error says that the vue-html2pdf component is not registered, but im not seeing anything wrong on your code.

I uploaded the nuxt project I test on try have a look on it: https://github.com/kempsteven/nuxt-tester/tree/main

from vue-html2pdf.

NanyThery avatar NanyThery commented on June 14, 2024

Thank you so much for the time you put into this. I'll give you feedback as soon as I can test it. Thanks again.

from vue-html2pdf.

NanyThery avatar NanyThery commented on June 14, 2024

Hi again!

An update on this. I did the following and even having copied directly your page and component, still, throws me the error of "have you registered the component"?.

  1. Copied exactly the same line in nuxt.config plugins.
  2. Installed Babel-core, since I noticed you had it in your package and I didn't
  3. I copied and pasted your pages/index and also your content-pdf component in my project to test it as is.

Still getting the same error. I am not really sure what it is.

But if it is working in your naked project, there must be something I've installed interfering with the app... I googled a lot but couldn't find anything that puts me in the right direction. I think I've tried all the combinations possible.

I am using Nuxt 2.14, but I don't think it's relevant for the case.

Thank you again for your time.

Kind regards,

Nadine

from vue-html2pdf.

kempsteven avatar kempsteven commented on June 14, 2024

Hello, I'm not exactly sure whats wrong, the main issue is that the component is not registering.

I tried replicating this in a couple of nuxt application types (SSR and JAMStack), still no success in replicating the issue.
You could try implementing this in a new nuxt application and compare the two projects and see what could have been the issue.

Good luck!

from vue-html2pdf.

kempsteven avatar kempsteven commented on June 14, 2024

Cool :D

from vue-html2pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.