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