懒加载组件或者元素的Vue指令 - vue-lazy-component

2016-09-10      38      Vue
项目简介

vue-lazy-component

懒加载组件或者元素的Vue指令,懒加载一些不在第一屏的组件可以提高vue初始化性能。

使用方法

import Vue from 'vue';
import lazy from 'vue-lazy-component';

Vue.use(lazy);
<!--Lazy load the element, 3s-->
<div v-lazy="3000">
    <p>Chlid</p>
    <component></component>
</div>
<!--Lazy load the component-->
<component v-lazy="3000"></component>

<!--Lazy load 0s, the effect is like setTimeout(fn, 0) -->
<component v-lazy></component>

创建步骤

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build the component to UMD js
npm run build

# build the dev page
npm run build:demo