vue ssr 组件使用document 、window对象 加载问题

            <template>
              <div>
                <Loading></Loading>
              </div>
            </template>

            <script type="text/babel">
              export default {
                data(){
                  return {
                        }
                },
                beforeMount() {
                  // 只会在浏览器执行  
                  this.$options.components.Loading = () =>import('vue-loading');
                },
                mounted(){
                }
              }
            </script>

使用beforeMount 函数去加载组件,这样组件在服务端就不会渲染,组件还可以配合v-if去控制组件的渲染

参考文章