[Vue] Load components when needed with Vue async components
In large applications, dividing the application into smaller chunks is often times necessary. In this lesson, we will look at how vue loads async components into your application.
<template>
<div>
<section class="pa2">
<h2>Lazy loading...</h2>
<button @click="show = true">Lazy load</button>
<div v-if="show">
<Async></Async>
</div>
</section>
</div>
</template> <script> const Async = resolve => {
console.log('loading...')
setTimeout(() => {
require(['~components/async.vue'], resolve)
console.log('loaded')
}, 1000)
} export default {
components: {
Async
},
data () {
return {
show: false
}
}
}
</script>
[Vue] Load components when needed with Vue async components的更多相关文章
- [Vue @Component] Handle Errors and Loading with Vue Async Components
Because async components are not bundled with your app, they need to be loaded when requested. This ...
- Vue中mixins、extends、extend和components的作用和区别
关于mixins:官方文档: https://cn.vuejs.org/v2/guide/mixins.html 一.components Vue.component是用来注册或获取全局组件的方法,其 ...
- 前端笔记之Vue(七)Vue-router&axios&Vue插件&Mock.js&cookie|session&加密
一.Vue-router(路由) 1.1路由创建 官网:https://router.vuejs.org/zh/ 用 Vue.js + Vue Router 创建单页应用,是非常简单的.使用 Vue. ...
- [Vue + TS] Using Route events inside Vue
vue-router introduces new hooks into the component. In this lesson we’ll show you how to use these n ...
- 小白学习VUE第二课:环境搭建 VUE Node.js VSCode template模板
环境搭建 VUE Node.js VSCode template模板: 首先安装node:http://www.runoob.com/nodejs/nodejs-install-setup.html ...
- vue+node+es6+webpack创建简单vue的demo
闲聊: 小颖之前一直说是写一篇用vue做的简单demo的文章,然而小颖总是给自己找借口,说没时间,这一没时间一下就推到现在了,今天抽时间把这个简单的demo整理下,给大家分享出来,希望对大家也有所帮助 ...
- vue学习笔记(四)——Vue实例以及生命周期
1.Vue实例API 1.构造器(实例化) var vm = new Vue({ //选项 |-------DOM(3) | |-------el (提供一个在页面上已存在的 DOM 元素作为 V ...
- Vue.js-11:第十一章 - Vue 中 ref 的使用
一.前言 在之前的前端开发中,为了实现我们的需求,通常采用的方案是通过 JS/Jquery 直接操纵页面的 DOM 元素,得益于 Jquery 对于 DOM 元素优异的操作能力,我们可以很轻易的对获取 ...
- vue实现部分页面导入底部 vue配置公用头部、底部,可控制显示隐藏
vue实现部分页面导入底部 vue配置公用头部.底部,可控制显示隐藏 在app.vue文件里引入公共的header 和 footer header 和 footer 默认显示,例如某个页面不需要显示h ...
随机推荐
- 【面试加分项】java自己定义注解之申明注解
之前的博客http://blog.csdn.net/u010590685/article/details/47029447介绍了java的注解的基本知识今天我们学习怎样使用自己定义注解. 首先我们要声 ...
- 洛谷P1439 最长公共子序列(LCS问题)
题目描述 给出1-n的两个排列P1和P2,求它们的最长公共子序列. 输入输出格式 输入格式: 第一行是一个数n, 接下来两行,每行为n个数,为自然数1-n的一个排列. 输出格式: 一个数,即最长公共子 ...
- javafx style and cssFile
public class EffectTest extends Application { public static void main(String[] args) { launch(args); ...
- vue中 v-cloak 的用法
原文来自:http://www.sunzhongwei.com/hide-vuejs-variable-with-v-cloak-when-page-loading
- 分享一个表格插入和删除编辑功能用jQuery实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- python 补0的方法
# 方法一 z = 'bb' z.zfill(6) ----'0000bb' n = ' n.zfill(5) ----' # 方法二 ' " ---- '报错' # 方法的区别 方法二只能 ...
- [React Native] Animate the Scale of a React Native Button using Animated.spring
In this lesson we will use Animated.spring and TouchableWithoutFeedback to animate the scale of a bu ...
- lighttpd启动不了,libssl.so.4&libcrypto.so.4 缺失
lighttd的出错日志在 log/out_lighttpd 里,当lighttd启动不了时候,这里文件中会说明原因. 今天的报错是 error while loading shared librar ...
- javascript创建对象的方法--动态原型模式
javascript创建对象的方法--动态原型模式 一.总结 1.作用:解决组合模式的属性和函数分离问题 2.思路:基本思路和组合模式相同:共用的函数和属性用原型方式,非共用的的函数和属性用构造函数 ...
- Date类的用法
package example; import java.text.DateFormat; import java.text.ParseException; import java.text.Simp ...