16 Star 87 Fork 21

Devifish/vue-better-scroller

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

vue-better-scroller

一款基于 better-scroll.js (已内置依赖无需导包)
为 vue.js 提供 scroll 滚动,上拉加载, 下拉刷新
使用 es6, vue-cli 3 构建

特点

  • 得益于 better-scroll 使用 css3 transform3d 硬件加速实现滚动
    即使千条数据也不会有卡顿掉帧
  • 使用 css3 calc 实现内部高度,避免使用原生better-scroll的不愉快
  • 尽量减少用户配置可渐进式添加功能

安装

NPM安装

$ npm install vue-better-scroller

也可手动下载Common JS 及 UMD JS手动导入 编译好的js文件 放于 dist 文件夹

使用

main.js 文件中引入插件并注册

# main.js
import Scroll from "vue-better-scroller";
Vue.use(Scroll)
<template>
  <scroll>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
  </scroll>
</template>

文档

组件 attr 参数文档

名称 功能 默认值 可选值
data 用于监听数据变化停止上拉下拉状态 object / array
scrollbar 是否显示滚动条 false true / false
direction(开发中) 滚动方向 vertical vertical / horizontal
bounce 各方向回弹效果开关 { top: true, bottom: true, left: true, right: true } 修改相应参数即可
options 可选功能(如开启关闭上拉加载下拉刷新) { pullup: false, pulldown: false, click: true, probeType: 0 } 修改相应参数即可

例子

  • 单独使用滚动(添加滚动回弹效果及滚动条)

      <scroll :scrollbar="true">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
      </scroll>
    
  • 添加上拉刷新及下拉加载

      <scroll :options="{ pullup: true, pulldown: true }" :ref="scroll">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
      </scroll>
    

    注意: 在上拉加载结束后需要调用

      this.$refs.scroll.pullupEnd();
    

    关闭上拉加载功能

效果

下面截图于本人公司项目DEMO实现 因此无法提供DEMO代码

The MIT License (MIT) Copyright (c) 2018 Devifish Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一款基于 better-scroll.js 为 vue.js 提供 scroll 滚动,上拉加载, 下拉刷新功能扩展组件 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Devifish/vue-better-scroller.git
git@gitee.com:Devifish/vue-better-scroller.git
Devifish
vue-better-scroller
vue-better-scroller
master

搜索帮助