Vue-awesome-swiper: window is undefined with SSR build with vue-hackernews-2.0

Created on 22 Mar 2017  路  3Comments  路  Source: surmon-china/vue-awesome-swiper

I import he vue-awesome-swiper/ssr in app.js and use it with Vue.use.
But, when I use swiper in a components throw a exception that window is not defined
So... I make some mistake? How can I use with SSR... Thx~

vue-hackernews-2.0

Most helpful comment

import Vue from 'vue'

// You need to make sure that you are introducing it in a browser build environment
if (process.BROWSER_BUILD) {
    const VueAwesomeSwiper = require('vue-awesome-swiper/ssr')
    Vue.use(VueAwesomeSwiper)
}

All 3 comments

import Vue from 'vue'

// You need to make sure that you are introducing it in a browser build environment
if (process.BROWSER_BUILD) {
    const VueAwesomeSwiper = require('vue-awesome-swiper/ssr')
    Vue.use(VueAwesomeSwiper)
}

@surmon-china I know what should I do and I appreciate that you can reply for me.

i have the same quetion . can you tell me what should i do?

Was this page helpful?
0 / 5 - 0 ratings