Giter Site home page Giter Site logo

Comments (12)

Beisenbayev avatar Beisenbayev commented on August 21, 2024 18

Solution:

  1. You have to create a vue-pdf-embed.js file inside the plugins folder in your project.
    plugins:
    |-vue-pdf-embed.js

  2. In this file import Vue and vue-pdf-embed (The problem was because of this step. Make sure about your version of nuxt. If you are using Nuxt3 (vue3) - then import from vue-pdf-embed)

vue-pdf-embed.js:

    import Vue from 'vue'
    import VuePdfEmbed from 'vue-pdf-embed/dist/vue2-pdf-embed'
    Vue.use(VuePdfEmbed)
    Vue.component('vue-pdf-embed', VuePdfEmbed)
  1. In nuxt.config.js file you have a plugins array. Add this line to an array: (read more)
    { src: '~/plugins/vue-pdf-embed.js', ssr: false, mode: 'client' }

from vue-pdf-embed.

abdmdjr avatar abdmdjr commented on August 21, 2024 9

In Nuxt 3, create a file in /plugins and name it vue-pdf-embed.client.ts with this code ->

import VuePdfEmbed from "vue-pdf-embed";

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.component("vue-pdf-embed", VuePdfEmbed);
});

In your page/component, use it like that :
<vue-pdf-embed :source="post.file" />

from vue-pdf-embed.

zguig52 avatar zguig52 commented on August 21, 2024 2

Done :)! I did not found this topic waiting for an answer

from vue-pdf-embed.

 avatar commented on August 21, 2024 1

this worked for me:

// plugins/vue-pdf-embed.client.ts

export default defineNuxtPlugin( nuxtApp => {
    const vuePdfEmbed = defineAsyncComponent(() => import('vue-pdf-embed'))
    nuxtApp.vueApp.component("vue-pdf-embed", vuePdfEmbed)
})

from vue-pdf-embed.

hrynko avatar hrynko commented on August 21, 2024

Hi, can you please check if you can solve the problem as in #12?

from vue-pdf-embed.

Beisenbayev avatar Beisenbayev commented on August 21, 2024

Hi, can you please check if you can solve the problem as in #12?

Hi, the author of this issue left a comment about solving the problem, but I don't understand what exactly needs to be done?
#12 (comment)

from vue-pdf-embed.

getshaun24 avatar getshaun24 commented on August 21, 2024

Solution:

  1. You have to create a vue-pdf-embed.js file inside the plugins folder in your project.
    plugins:
    |-vue-pdf-embed.js
  2. In this file import Vue and vue-pdf-embed (The problem was because of this step. Make sure about your version of nuxt. If you are using Nuxt3 (vue3) - then import from vue-pdf-embed)

vue-pdf-embed.js:

    import Vue from 'vue'
    import VuePdfEmbed from 'vue-pdf-embed/dist/vue2-pdf-embed'
    Vue.use(VuePdfEmbed)
    Vue.component('vue-pdf-embed', VuePdfEmbed)
  1. In nuxt.config.js file you have a plugins array. Add this line to an array: (read more)
    { src: '~/plugins/vue-pdf-embed.js', ssr: false, mode: 'client' }

Thank you for the solution but I am still getting the Self Not Defined issue.

This is my vue-pdf-embed.js file

import Vue from 'vue'
import VuePdfEmbed from 'vue-pdf-embed'
Vue.use(VuePdfEmbed)
Vue.component('vue-pdf-embed', VuePdfEmbed)

and this is in my vue file

import VuePdfEmbed from 'vue-pdf-embed'
export default {
  components: {
    VuePdfEmbed,
  },
  data() {
    return {
      source1: "../../public/xxx.pdf",
    }
  },
}

Additionally, just installing this plugin is breaking all the js on my whole site.

Please can somebody help?!

Thank You :)

from vue-pdf-embed.

th4it4y4 avatar th4it4y4 commented on August 21, 2024

I got this problem too in NuxtJs 2.
So I add " { src: '~/plugins/vue-pdf-embed.js', ssr: false, mode: 'client' } " in my nuxt config and import lib in script but it have error "Plugin not found" plz help

from vue-pdf-embed.

honghuynhit avatar honghuynhit commented on August 21, 2024

Solution:

  1. You have to create a vue-pdf-embed.js file inside the plugins folder in your project.
    plugins:
    |-vue-pdf-embed.js
  2. In this file import Vue and vue-pdf-embed (The problem was because of this step. Make sure about your version of nuxt. If you are using Nuxt3 (vue3) - then import from vue-pdf-embed)

vue-pdf-embed.js:

    import Vue from 'vue'
    import VuePdfEmbed from 'vue-pdf-embed/dist/vue2-pdf-embed'
    Vue.use(VuePdfEmbed)
    Vue.component('vue-pdf-embed', VuePdfEmbed)
  1. In nuxt.config.js file you have a plugins array. Add this line to an array: (read more)
    { src: '~/plugins/vue-pdf-embed.js', ssr: false, mode: 'client' }

Very detail. Big thanks

from vue-pdf-embed.

terajoellang avatar terajoellang commented on August 21, 2024

I got this problem too in NuxtJs 2. So I add " { src: '~/plugins/vue-pdf-embed.js', ssr: false, mode: 'client' } " in my nuxt config and import lib in script but it have error "Plugin not found" plz help

Same issue here, did you find a solution?

from vue-pdf-embed.

zguig52 avatar zguig52 commented on August 21, 2024

Quick and easy steps for Nuxt3 integration as a plugin:

  1. Create a folder plugins

  2. Create a file named VuePdfEmbed.client.js inside the folder with following content:

import VuePdfEmbed from 'vue-pdf-embed'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VuePdfEmbed)
  nuxtApp.vueApp.component('VuePdfEmbed', VuePdfEmbed);
})

  1. Use it in your app like this:
      <ClientOnly>
        <VuePdfEmbed :source="pdfURL" />
      </ClientOnly>

from vue-pdf-embed.

hrynko avatar hrynko commented on August 21, 2024

HI @zguig52,

Could you duplicate your answer to #114?

from vue-pdf-embed.

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.