By default, vue-router doesn’t lazy load the routes unless you tell it to do it. Lazy loading of the non-critical routes is one of the points of the PRPL pattern.

This lesson will show you how you can use the dynamic import to lazy load non-critical routes.

When we using Vue dynamice import syntax:

  1. const router = new VueRouter({
  2. routes: [
  3. { path: '/images', component: () => import('./components/Images') },
  4. { path: '/images/:id', component: () => import('./components/Details'), props: true },
  5. { path: '/', redirect: '/images' }
  6. ]
  7. })

To enable that, we need to install:

  1. npm install babel-plugin-syntax-dynamic-import

.babelrc:

  1. {
  2. "plugins": ["syntax-dynamic-import"]
  3. }

[Vue] Lazy Load a Route by using the Dynamic Import in Vue.js的更多相关文章

  1. [Vue] Code split by route in VueJS

    In this lesson I show how to use webpack to code split based on route in VueJS. Code splitting is a ...

  2. [Vuex] Lazy Load a Vuex Module at Runtime using TypeScript

    Sometimes we need to create modules at runtime, for example depending on a condition. We could even ...

  3. Lazy Load, 延迟加载图片的 jQuery 插件.

    Lazy Load 是一个用 JavaScript 编写的 jQuery 插件. 它可以延迟加载长页面中的图片. 在浏览器可视区域外的图片不会被载入, 直到用户将页面滚动到它们所在的位置. 这与图片预 ...

  4. jQuery延迟加载插件(Lazy Load)详解

    最 新版本的Lazy Load并不能替代你的网页.即便你使用JavaScript移除了图片的src属性,有些现代的浏览器仍然会加载图片.现在你必须修改你的html代 码,使用占位图片作为img标签的s ...

  5. 延迟加载图片的 jQuery 插件:Lazy Load

    网站的速度非常重要,现在有很多网站优化的工具,如 Google 的Page Speed,Yahoo 的 YSlow,对于网页图片,Yahoo 还提供 Smush.it这个工具对图片进行批量压缩,但是对 ...

  6. Lazy Load 图片延迟加载(转)

    jQuery Lazy Load 图片延迟加载来源 基于 jQuery 的图片延迟加载插件,在用户滚动页面到图片之后才进行加载. 对于有较多的图片的网页,使用图片延迟加载,能有效的提高页面加载速度. ...

  7. jQuery Lazy Load 图片延迟加载

    基于 jQuery 的图片延迟加载插件,在用户滚动页面到图片之后才进行加载. 对于有较多的图片的网页,使用图片延迟加载,能有效的提高页面加载速度. 版本: jQuery v1.4.4+ jQuery ...

  8. about hibernate lazy load and solution

    about hibernate lazy load is that used when loaded again.it can increase efficienty and sava memory. ...

  9. Lazy Load, 延迟加载图片的 jQuery 插件 - NeoEase

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

随机推荐

  1. group by 和 select

    group by 有一个原则,就是 select 后面的所有列中,没有使用聚合函数的列,必须出现在 group by 后面.

  2. strcpy 和 memcpy自实现

    都是套路,详见代码注释: #include <stdio.h> #include <assert.h> #include <iostream> using name ...

  3. Intellij IDEA14配置

    一.下载 官网下载地址:http://www.jetbrains.com/idea/ 目前最新的版本是15,发现15注册比较麻烦,好像需要只能通过联网激活.而网上14的离线注册码一大堆,就下载了14, ...

  4. Failed to resolve com.android.support:support-annotations 26.0.1

    所有当前版本的Google库都存放在 Google的Maven repository (maven.google.com),不在旧的offline-capable support repositori ...

  5. JS——绑定自定义属性

    1.绑定自定义属性: (1)元素节点.属性或元素节点[属性]绑定的属性不会出现在标签中,setAttribute可以出现在标签中. (2)setAttribute获取不到元素节点.属性形式绑定的属性值 ...

  6. JS——if条件判断

    现在只说特殊情况: 1.一个变量,例如n1=null <script> var n1 = null; alert(n1);/*弹窗的值为null*/ if (n1 == null) {/* ...

  7. Ubuntu14.4安装mysql

    一.安装 apt-get install mysql-server mysql-client 设置用户名和密码 二.检查 sudo service mysql restart 三.支持 1.apach ...

  8. 几种fullpage用法及demo

    jQuery全屏滚动插件fullPage.js https://github.com/alvarotrigo/fullPage.js http://www.dowebok.com/77.html 全屏 ...

  9. day05-控制流程之if/while/for

    目录 控制流程之if判断 控制流程之while循环 控制流程之for循环 控制流程之if判断 if 其实就是根据条件来做出不同的反应,如果这样就这样干,如果那样就那样干 1. 如果:成绩 > 9 ...

  10. Python 之web动态服务器

    webServer.py代码如下: import socket import sys from multiprocessing import Process class WSGIServer(obje ...