vue-picture-swipe icon indicating copy to clipboard operation
vue-picture-swipe copied to clipboard

Add instructions for Nuxt

Open danchristian opened this issue 6 years ago • 6 comments

Trying to get this working with Nuxt. So far I have:

plugins/vue-picture-swipe.js

import Vue from 'vue'
import VuePictureSwipe from 'vue-picture-swipe'

Vue.component('vue-picture-swipe', VuePictureSwipe)

Do I also need a Vue.use(VuePictureSwipe) in this file?

nuxt.config.js

plugins: [
  { src: '~/plugins/vue-picture-swipe', ssr: false }
]

components/gallery.vue

<template lang="pug">
  div
    no-ssr
      vue-picture-swipe(:items="items")
</template>

As it's registered as a Nuxt plugin I don't have to import VuePictureSwipe from 'vue-picture-swipe' in the component.

I had to use the no-ssr tag otherwise I was getting:

The client-side rendered virtual DOM tree is not matching server-rendered content.

I'm not 100% why I have to use this as well as setting ssr: false in the nuxt.config.js file?

Any help would be great and hopefully the instructions can then be updated to include Nuxt usage?

danchristian avatar Jan 27 '19 12:01 danchristian

Hello, in your items object you must link your item image with src and thumbnail

images:[
     {
        thumbnail: image-thumbnail.jpg,
        src: image.jpg
     }
]

Cloudy998 avatar Jan 27 '19 22:01 Cloudy998

Hello and thank you for your contribution. I did not tried this package with Nuxt, and I'm not familiar with this tool so I don't know what instruction to write. I will try to test it with Nuxt soon!

rap2hpoutre avatar Jan 28 '19 13:01 rap2hpoutre

Thanks. I have got it working with Nuxt, although my initial questions still stand.

danchristian avatar Jan 28 '19 13:01 danchristian

@danchristian Could you share an example? I am getting this error: "Cannot use import statement outside a module".

retroriff avatar Aug 08 '21 16:08 retroriff

@retroriff I fixed this by adding: build: { transpile: ["vue-picture-swipe"], }, inside nuxt.config.js

K-Cyganiak avatar Sep 17 '21 20:09 K-Cyganiak

@K-Cyganiak That worked, thank you!

retroriff avatar Sep 22 '21 10:09 retroriff