vuepress 打包 :window is not defined

我在写vue-leaflet-more插件的文档中遇到的这个问题,对leaflet感兴趣的朋友也可以多多关注vue-leaflet-more哦 ~_~

1、问题描述:

项目中,引入leaflet插件,会必须要用到window对象,打包时,提示window不存在,由于打包在node中进行的,node无window概念

2、报错提示:

3、解决方案

在enhanceApp.js中设置

 可复制代码:

   Vue.mixin({
       mounted() {
            //你自己的插件地址
            import('../../src/index.js').then(module => {
                Vue.use(module.default);
            }).catch(err => {
                console.log(err);
            });
        },
    })

猜你喜欢

转载自blog.csdn.net/wanggmm/article/details/123405690