background

Window is not defined (undefined); window is not defined (undefined)

The solution

Use plugins in nuxt.js to solve this problem

Suppose the component library is called VUe-xxx

// nuxt.config.js write configuration
module.exports = {
    plugins: [
        '~/plugins/vue-xxx.client.js']}// vue-xxx.client.js
import Vue from 'vue';
import xxx from 'vue-xxx';
import 'xxx/lib/style.css';

if (process.browser) {
    Vue.use(xxx);
}
Copy the code
<! -- abc.vue We can now happily use components -->
<template>
    <div>
        <xxx-btn></xxx-btn>
    </div>
</template>
Copy the code