3.3.1 • Published 1 year ago

vue-waterfall-plugin v3.3.1

Weekly downloads
41
License
UNLICENSED
Repository
-
Last release
1 year ago

Vue2 瀑布流组件

vue 瀑布流插件,支持 PC 和移动端,支持 animate 的所有动画效果,支持图片懒加载

在线演示地址

vue3 版本

安装

npm install vue-waterfall-plugin

使用

import { LazyImg, Waterfall } from 'vue-waterfall-plugin'
import 'vue-waterfall-plugin/dist/style.css'
<Waterfall :list="list">
  <template #item="{ item, url, index }">
    <div class="card">
      <LazyImg :url="url" />
      <p class="text">这是内容</p>
    </div>
  </template>
</Waterfall>
data: {
  list: [
    {
      src: "xxxx.jpg",
      ...
    }
    ...
  ]
}

作用域插槽返回了3个字段: item 原始数据, url 图片资源, index 卡片索引

Props 参数

参数名类型默认值描述
listArray[]列表数据
rowKeyStringid数据唯一的字段,比如列表里面的id, 如果要删除卡片,该字段为必填
imgSelectorStringsrc图片字段选择器,如果层级较深,使用 xxx.xxx.xxx 方式
widthNumber200卡片在 PC 上的宽度
breakpointsObjectbreakpoints自定义行显示个数,主要用于对移动端的适配
gutterNumber10卡片之间的间隙
hasAroundGutterBooleantrue容器四周是否有 gutter 边距
animationPrefixStringanimate__animatedanimate.css 的动画绑定 className,默认的是 4.x.x 版本,如果想使用老版本,只需要改成 animated 即可
animationEffectStringfadeIn卡片入场动画,默认只有 fadeIn,引入 animation.css 后可使用其他动画
animationDurationNumber1000动画执行时间(单位毫秒)
animationDelayNumber300动画延迟(单位毫秒)
backgroundColorString#ffffff背景颜色
loadPropsObjectloadProps加载的图片和失败的图片
lazyloadBooleantrue是否开启懒加载
delayNumber300布局刷新的防抖时间,默认 300ms 内没有再次触发才刷新布局。(图片加载完成;容器大小、listwidthgutterhasAroundGutter变化时均会触发刷新)

breakpoints

breakpoints: {
  1200: { //当屏幕宽度小于等于1200
    rowPerView: 4,
  },
  800: { //当屏幕宽度小于等于800
    rowPerView: 3,
  },
  500: { //当屏幕宽度小于等于500
    rowPerView: 2,
  }
}

loadProps

import loading from 'assets/loading.png'
import error from 'assets/error.png'
loadProps: {
  loading,
  error
}

懒加载图片样式覆盖,需要将覆盖样式放在全局才能生效

.lazy__img[lazy=loading] {
  padding: 5em 0;
  width: 48px;
}

.lazy__img[lazy=loaded] {
  width: 100%;
}

.lazy__img[lazy=error] {
  padding: 5em 0;
  width: 48px;
}
3.3.1

1 year ago

3.3.0

1 year ago

3.2.0

1 year ago

3.1.0

2 years ago

3.0.0

3 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago