FastClick
js手法
if ('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}
VueLazyComponent
组件 懒加载:组件1秒钟之后再加载;
<vue-lazy-component :timeout="1000">
<st-series-sohu/>
<st-series-sohu-skeleton slot="skeleton"/>
</vue-lazy-component>
CompressionWebpackPlugin
文件压缩;
注:此配置需要后台同步设置nginx,nginx配置可搜索nginx配置压缩
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const productionGzipExtensions = ['js', 'css'];
module.exports = {
publicPath: './',
configureWebpack: {
externals: {
'vue': 'Vue',
'vue-router': 'VueRouter',
'axios': 'axios',
'Qs': 'QS',
'vue-lazyload': 'VueLazyload',
'element-ui': 'ELEMENT'
},
plugins: [
new CompressionWebpackPlugin({
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
]
}
}