[Vuejs]-Nuxtjs use component vue-pano

0👍

to use any vue plugin that makes use of window or document, you need to wrap them in a <no-ssr></no-ssr> component (provided by nuxt).

With

if (process.browser) {
Vue.component(‘Pano’, require(‘vue-pano’))
}

you are registering globally the component if the context is browser. But what you would like to do isntead is to import it only in browser mode:

const noSSRComponents = {};

if (process.browser) {
    const vuePano = require('vue-pano');
    noSSRComponents.vuePano = vuePano;
}
export default {
// ...
    components: {
        ...noSSRComponents,
    }
}

Leave a comment