vue-lazyload基础实例(基于vue2.0和vue-router2.0)
2017-07-27 22:29
1216 查看
首先引入依赖
2
3
1
2
3
配置vue-lazyload
2
3
4
5
6
7
1
2
3
4
5
6
7
模版部分
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
css
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
原文地址:http://blog.csdn.net/blueblueskyhua/article/details/64124240
项目完整实例地址:https://github.com/hua1995116/vue/tree/master/vue-lazyload
lazy-load api 地址https://www.npmjs.com/package/vue-lazyload
import Vue from 'vue'; import Router from 'vue-router'; import VueLazyload from 'vue-lazyload';1
2
3
1
2
3
配置vue-lazyload
Vue.use(VueLazyload, { preLoad: 1.3, error: './img/error.jpg', loading: 'http://cdn.uehtml.com/201402/1392662591495_1140x0.gif', attempt: 1, listenEvents: [ 'scroll', 'mousewheel' ] });1
2
3
4
5
6
7
1
2
3
4
5
6
7
模版部分
<div class="hello"> <ul> <li v-for="item in imgUrl"> <img v-lazy="item.src" alt="" width="300" height="150"/> </li> </ul> </div> export default { name: 'hello', data() { return { imgUrl: [ {src: 'http://pic.58pic.com/58pic/11/25/25/46j58PICKMh.jpg'}, {src: 'http://pic.58pic.com/58pic/11/25/25/46j58PICKMh.jpg'}, {src: 'http://pic.58pic.com/58pic/11/25/25/46j58PICKMh.jpg'}, {src: 'http://pic.58pic.com/58pic/11/25/25/46j58PICKMh.jpg'} ] }; } };1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
css
img[lazy=loading]{ //your code } img[lazy=loaded]{ //your code animation:fade 0.5s; } @keyframes fade { 0%{ opacity: 0; } 100%{ opacity: 1; } }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
原文地址:http://blog.csdn.net/blueblueskyhua/article/details/64124240
项目完整实例地址:https://github.com/hua1995116/vue/tree/master/vue-lazyload
lazy-load api 地址https://www.npmjs.com/package/vue-lazyload
相关文章推荐
- vue-lazyload基础实例(基于vue2.0和vue-router2.0)
- vue-router 2.0 常用基础知识点之导航钩子
- 详解vue-router 2.0 常用基础知识点之导航钩子
- vue-router 2.0 常用基础知识点之router.push()
- vue-router 2.0 常用基础 4000 知识点之router.push()
- Vue-router2.0基础实践
- vue2.0---vue-router总结(项目基于vue-cli)
- vue2.0+基础知识连载(01)--- Vue实例简介
- vue-router 2.0 常用基础知识点之router-link
- vue-router 2.0 常用基础知识点之router.push()
- vue-router 2.0 常用基础知识点之router.push()
- Vue2.0基于vue-cli+webpack Vuex的用法(实例讲解)
- vue.js中Vue-router 2.0基础实践教程
- Vue 2.0 起步(2) 组件及 vue-router实例 - 微信公众号RSS
- Vue2.0基础学习(3)--- 一个简单的实例学习
- vue-router 2.0 常用基础知识点之router.push()
- 详解vue-router 2.0 常用基础知识点之router-link
- vue-router 2.0 常用基础知识点之router-link
- Vue-router2.0基础实践
- 从零开始,零基础,一点一点探索vue-router(vue2.0)