vuepress & ReferenceError: window is not defined


vuepress & ReferenceError: window is not defined

bug

✔ Client
  Compiled successfully in 15.35s

✔ Server
  Compiled successfully in 8.27s

wait Rendering static HTML...
error Error rendering /guide/: false
undefined
error Error rendering /config/: false
undefined
error Error rendering /: false
undefined
error Error rendering /guide/multi-select.html: false
undefined
error Error rendering /404.html: false
undefined
ReferenceError: window is not defined

solution 🚀✅

Async/Await & dynamic import module

// import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import '../../lib/gui.css';

export default async ({
    Vue, // the version of Vue being used in the VuePress app
    options, // the options for the root Vue instance
    router, // the router instance for the app
    siteData, // site metadata,
    isServer
}) => {
    // 使用 element-ui
    Vue.use(ElementUI);
    // 使用 gui
    if (!isServer) {
        await import('../../lib/gui.common.js').then(module => {
            Vue.use(module.default);
        });
    }
}

refs

https://www.cnblogs.com/xgqfrms/p/14421995.html



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!



免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM