vue疑难杂症

Published 07-05-2019 16:35:33

vue首页白屏(几率性)

// 在config文件夹中找到index.js打开把
assetsPublicPath: '/'
// 改成
assetsPublicPath: './'
// 再次执行 npm run build 就可以了。

消除transition闪屏

.css { 
    -webkit-transform-style: preserve-3d; 
    -webkit-backface-visibility: hidden; 
    -webkit-perspective: 1000; 
} 

history模式下404

// 服务器的404页面需要重定向到index.html(nginx)
try_files $uri $uri/ /index.html;

解决vue打包vendor过大

  1. 在webpack.base.conf.js新增externals配置,表示不需要打包的文件,然后在index.html中通过CDN引入
externals: {
    "vue": "Vue",
    "vue-router": "VueRouter",
    "vuex": "Vuex",
    "element-ui": "ELEMENT",
    "BMap": "BMap"
  }

2、使用路由懒加载

网站被劫持植入广告

  1. https,最稳

  2. 在网站页头加入如下代码:

    <style> html{display : none ; } </style>   
    <script>  
    if( self == top ) {  
          document.documentElement.style.display = 'block' ;  
    } else {  
       top.location = self.location ;  
    }  
    </script>