同人那个小说网站做的最好,诸暨市建设局网站,潍坊市建设工程管理处网站,汕头网站建设培训公司第050个 查看专栏目录: VUE ------ element UI 专栏目标
在vue和element UI联合技术栈的操控下#xff0c;本专栏提供行之有效的源代码示例和信息点介绍#xff0c;做到灵活运用。 #xff08;1#xff09;提供vue2的一些基本操作#xff1a;安装、引用#xff0c;模板使… 第050个 查看专栏目录: VUE ------ element UI 专栏目标
在vue和element UI联合技术栈的操控下本专栏提供行之有效的源代码示例和信息点介绍做到灵活运用。 1提供vue2的一些基本操作安装、引用模板使用computedwatch生命周期(beforeCreatecreated,beforeMountmounted, beforeUpdateupdated, beforeDestroydestroyedactivateddeactivatederrorCapturedcomponents)、 $root , $parent , $children , $slots , $refs , props, $emit , eventbus ,provide / inject, Vue.observable, $listeners, $attrs, $nextTick , v-for, v-if, v-else,v-else-ifv-onv-prev-cloakv-oncev-model v-html, v-text, keep-aliveslot-scope filters, v-bind.stop, .native, directivesmixinrender国际化Vue Router等 2提供element UI的经典操作安装引用国际化el-rowel-colel-buttonel-linkel-radioel-checkbox el-inputel-select, el-cascader, el-input-number, el-switch,el-slider, el-time-picker, el-date-picker, el-upload, el-rate, el-color-picker, el-transfer, el-form, el-table, el-tree, el-pagination,el-badge,el-avatar,el-skeleton, el-empty, el-descriptions, el-result, el-statistic, el-alert, v-loading, $message, $alert, $prompt, $confirm , $notify, el-breadcrumb, el-page-header,el-tabs ,el-dropdown,el-steps,el-dialog, el-tooltip, el-popover, el-popconfirm, el-card, el-carousel, el-collapse, el-timeline, el-divider, el-calendar, el-image, el-backtopv-infinite-scroll el-drawer等 本文章目录 专栏目标应用场景安装插件vue.config.js 配置webpack-bundle-analyzer 是什么相关API 应用场景
vue项目中不做处理通常首页文件比较大影像加载速度。解决办法是通过webpack将大文件分解为小文件具体的一个vue.config.js文件参考。
安装插件 npm install --save-dev webpack-bundle-analyze vue.config.js 配置
onst BundleAnalyzerPlugin require(webpack-bundle-analyzer).BundleAnalyzerPlugin; module.exports { publicPath: ./, assetsDir: static, productionSourceMap: false, devServer: { proxy: { /api:{ target:http://xxx.xxx.xxx.xxx:1234, changeOrigin:true, pathRewrite:{ ^/api:/api } } } }, chainWebpack: config { if (process.env.NODE_ENV production) { // 移除 prefetch 插件 config.plugins.delete(prefetch); } }, configureWebpack: (config) { const res { plugins: [] }; if (process.env.NODE_ENV production) { res.plugins.push(new BundleAnalyzerPlugin()), res.optimization { splitChunks: { // chunks: async, // minSize: 300000, maxSize: 650000, // maxAsyncRequests: 5, // maxInitialRequests: 3, cacheGroups: { vendors: { name: chunk-vendors, test: /[\\/]node_modules[\\/]/, chunks: initial, priority: 2, reuseExistingChunk: true, enforce: true }, common: { name: chunk-common, chunks: initial, minChunks: 2, maxInitialRequests: 5, minSize: 0, priority: 1, reuseExistingChunk: true, enforce: true }, elementui: { test:/[\\/]node_modules[\\/]element-ui[\\/]/, //匹配要拆分的模块 name: chunk-elementui, chunks: all, priority: 3, reuseExistingChunk: true, enforce: true }, echarts: { test: /[\\/]node_modules[\\/](vue-)?echarts[\\/]/, name: chunk-echarts, chunks: all, priority: 4, reuseExistingChunk: true, enforce: true }, xlsx: { test: /[\\/]node_modules[\\/]xlsx[\\/]/, name: chunk-xlsx, chunks: all, priority: 3, reuseExistingChunk: true, enforce: true } } } } } return { ...res } }, // css相关配置 css: { extract: true, // 是否使用css分离插件 ExtractTextPlugin sourceMap: false, // 开启 CSS source maps? loaderOptions: { css: { }, // 这里的选项会传递给 css-loader }, // css预设器配置项 详见https://cli.vuejs.org/zh/config/#css-loaderoptions modules: false // 启用 CSS modules for all css / pre-processor files. }, } webpack-bundle-analyzer 是什么
webpack-bundle-analyzer 是 webpack 的插件需要配合 webpack 和 webpack-cli 一起使用。这个插件可以读取输出文件夹通常是 dist中的 stats.json 文件把该文件可视化展现生成代码分析报告可以直观地分析打包出的文件有哪些及它们的大小、占比情况、各文件 Gzipped 后的大小、模块包含关系、依赖项等对应做出优化从而帮助提升代码质量和网站性能。
相关API
https://www.npmjs.com/package/webpack-bundle-analyzer