Gathering detailed insights and metrics for vue-waterfall2
Gathering detailed insights and metrics for vue-waterfall2
Gathering detailed insights and metrics for vue-waterfall2
Gathering detailed insights and metrics for vue-waterfall2
npm install vue-waterfall2
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
46
lazy-src
)If you have some questions,welcome to describe issues、suggestions;Thank you for your Star !
Welcome to my blog !!!
Common Demo
Lazyload Demo
Code Demo
npm i
npm run dev
npm i vue-waterfall2@latest --save
Name | Default | Type | Desc |
---|---|---|---|
height | null | Number | height of container |
col | 2 | Number | The number of column |
width | null | Number | The width of each column |
gutterWidth | 10 | Number | The value of margin |
data | [] | Array | data |
isTransition | true | Boolean | load image with transition |
lazyDistance | 300 | Number | The distance of image lazy loading |
loadDistance | 300 | Number | The distance of loadmore |
For images that need to be loaded lazily, the 'lazy-src' attribute needs to be used
1<waterfall :col='col' :data="data" > 2 <img v-if="item.img" :lazy-src="item.img" alt="load error" /> 3</waterfall>
Name | Data | Desc |
---|---|---|
loadmore | - | Scroll to the bottom to trigger on PC / pull up to trigger on Mobile |
scroll | obj | Scroll to trigger and get the infomation of scroll |
finish | - | finish render |
this.$waterfall.forceUpdate() //forceUpdate
Notes:
rem
to layout, calculate the width after adaptation before passing the value.scoped
and try it1import { createApp } from "vue"; 2import waterfall from 'vue-waterfall2' 3 4const app = createApp(App) 5app.use(waterfall)
1<template> 2 <div class="container-water-fall"> 3 <div><button @click="loadmore">loadmore</button> <button @click="mix">mix</button> <button @click="switchCol('5')">5列</button> <button @click="switchCol('8')">8列</button> <button @click="switchCol('10')">10列</button> </div> 4 5 <waterfall :col='col' :width="itemWidth" :gutterWidth="gutterWidth" :data="data" @loadmore="loadmore" @scroll="scroll" > 6 <div class="cell-item" v-for="(item,index) in data"> 7 <div class="item-body"> 8 <div class="item-desc">{{item.title}}</div> 9 <div class="item-footer"> 10 <div class="avatar" :style="{backgroundImage : `url(${item.avatar})` }"></div> 11 <div class="name">{{item.user}}</div> 12 <div class="like" :class="item.liked?'active':''" > 13 <i ></i> 14 <div class="like-total">{{item.liked}}</div> 15 </div> 16 </div> 17 </div> 18 </div> 19 </waterfall> 20 21 </div> 22</template> 23 24 25/* 26 notes: 27 1. when using `rem` to layout, calculate the width after adaptation before passing the value. 28 2. Use the parent component of 'waterfall' if there is a problem with the style, remove CSS 'scoped' and try it 29*/ 30 31import Vue from 'vue' 32 export default{ 33 data(){ 34 return{ 35 data:[], 36 col:5, 37 } 38 }, 39 computed:{ 40 itemWidth(){ 41 return (138*0.5*(document.documentElement.clientWidth/375)) #rem to layout, Calculate the value of width 42 }, 43 gutterWidth(){ 44 return (9*0.5*(document.documentElement.clientWidth/375)) #rem to layout, Calculate the value of margin 45 } 46 }, 47 methods:{ 48 scroll(scrollData){ 49 console.log(scrollData) 50 }, 51 switchCol(col){ 52 this.col = col 53 console.log(this.col) 54 }, 55 loadmore(index){ 56 this.data = this.data.concat(this.data) 57 } 58 } 59 }
No vulnerabilities found.
No security vulnerabilities found.