TerryZ / v-gallery

A Vue2 plugin for images show in gallery or carousel
https://terryz.github.io/vue/#/gallery
MIT License
61 stars 17 forks source link

v-gallery vuepress #8

Open shriaviator opened 3 years ago

shriaviator commented 3 years ago

using v-gallery in vue press

v-gallery works satis during dev Below error during build

ReferenceError: document is not defined at n (node_modules/v-gallery/dist/v-gallery.js:1:2026) at o (node_modules/v-gallery/dist/v-gallery.js:1:1856) at t.exports (node_modules/v-gallery/dist/v-gallery.js:1:3540) at Object.<anonymous> (node_modules/v-gallery/dist/v-gallery.js:1:14711) at e (node_modules/v-gallery/dist/v-gallery.js:1:348) at Object.<anonymous> (node_modules/v-gallery/dist/v-gallery.js:1:3903) at e (node_modules/v-gallery/dist/v-gallery.js:1:348) at Object.<anonymous> (node_modules/v-gallery/dist/v-gallery.js:1:11594) at e (node_modules/v-gallery/dist/v-gallery.js:1:348) at Object.<anonymous> (node_modules/v-gallery/dist/v-gallery.js:1:11471) at e (node_modules/v-gallery/dist/v-gallery.js:1:348) at server-bundle.js:6537:566

TerryZ commented 3 years ago

You can try dynamically import

https://vuepress.vuejs.org/guide/using-vue.html

https://github.com/vuejs/vuepress/issues/442

shriaviator commented 3 years ago
TerryZ commented 3 years ago

.vuepress/enhanceApp.js file for example


import Gallery from 'v-gallery'

export default ({
  Vue,
  options,
  router,
  siteData
}) => {
  if (typeof process === 'undefined') {
    Vue.use(Gallery)
  }
}

or

export default ({
  Vue,
  options,
  router,
  siteData
}) => {
  import('v-gallery').then(resp => {
    Vue.use(resp.default)
  })
}

More references: https://vuepress-examples.netlify.app/demos/plugins/

shriaviator commented 3 years ago