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

This is how to get it working in Nuxt (or get rid of "document is not defined") #18

Open
Knogobert opened this issue Jan 28, 2021 · 3 comments

Comments

@Knogobert
Copy link

The issue is that document is not available when server-side rendering.

Create a plugin file with this name and content:

plugins/client-only.pinch-zoom.js:

import Vue from 'vue'

export default () => {
	const PinchZoom = require('vue-pinch-zoom')
	Vue.component('pinch-zoom', PinchZoom);
}

Then add this to your plugins in nuxt.config.js:

plugins: [{ src: 'plugins/client-only.pinch-zoom.js', mode: 'client'  }],

This will then globally register your component on the client-side only, and you will not get the error of " document is not defined" on build.

Hopefully this helps someone

@shi11
Copy link

shi11 commented Apr 29, 2021

thanks, this was helpful. However now Im getting

TypeError: Cannot read property 'tagName' of null at new IvyPinch (PinchZoom.umd.js:3962) at VueComponent.PinchZoom.init (PinchZoom.umd.js:4527) at VueComponent.PinchZoom.mounted (PinchZoom.umd.js:4477)

and TypeError: Cannot read property 'destroy' of undefined

@Chitzi
Copy link

Chitzi commented Aug 8, 2021

Same here

@juventus18
Copy link

juventus18 commented Dec 9, 2021

I am also getting the errors:
TypeError: Cannot read property 'tagName' of null at new IvyPinch (PinchZoom.umd.js:3962) at VueComponent.PinchZoom.init (PinchZoom.umd.js:4527) at VueComponent.PinchZoom.mounted (PinchZoom.umd.js:4477)

and TypeError: Cannot read property 'destroy' of undefined

I am only doing a client build (no SSR)

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

4 participants