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

Self in not defined in Nuxt.js #21

Closed
Beisenbayev opened this issue Apr 8, 2022 · 12 comments
Closed

Self in not defined in Nuxt.js #21

Beisenbayev opened this issue Apr 8, 2022 · 12 comments

Comments

@Beisenbayev
Copy link

image

@hrynko
Copy link
Owner

hrynko commented Apr 8, 2022

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

@Beisenbayev
Copy link
Author

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)

@Beisenbayev
Copy link
Author

Beisenbayev commented Apr 9, 2022

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' }

@getshaun24
Copy link

getshaun24 commented Jan 6, 2023

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 :)

@abdmdjr
Copy link

abdmdjr commented Jan 26, 2023

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" />

@ghost
Copy link

ghost commented May 11, 2023

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)
})

@th4it4y4
Copy link

th4it4y4 commented May 16, 2023

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

@honghuynhit
Copy link

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

@terajoellang
Copy link

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?

@zguig52
Copy link

zguig52 commented Oct 3, 2023

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>

@hrynko
Copy link
Owner

hrynko commented Oct 3, 2023

HI @zguig52,

Could you duplicate your answer to #114?

@zguig52
Copy link

zguig52 commented Oct 3, 2023

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

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

8 participants