├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── README.md ├── babel.config.js ├── package.json ├── public ├── favicon.ico └── index.html └── src ├── App.vue ├── VirtualListScroll └── index.vue ├── index.js └── main.js /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | 'extends': [ 7 | 'plugin:vue/essential', 8 | 'eslint:recommended' 9 | ], 10 | parserOptions: { 11 | parser: 'babel-eslint' 12 | }, 13 | rules: { 14 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 15 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [Demo](https://virtual-list-scroll-xfy196.vercel.app/) 2 | ### Install 3 | 4 | ```shell 5 | npm i virtual-list-scroll 6 | ``` 7 | 8 | ### Import 9 | 10 | ```shell 11 | import Vue from "vue" 12 | import VirtualListScroll from "virtual-list-scroll" 13 | Vue.use(VirtualListScroll) 14 | ``` 15 | 16 | ### Usage 17 | 18 | ### Page Mode 19 | 20 | ```vue 21 | 22 | 23 | 24 | ``` 25 | 26 | ### Container Mode 27 | 28 | ```vue 29 | 30 | 31 | 32 | 33 | ``` 34 | 35 | ### Flxed Block Height 36 | 37 | ```vue 38 | 44 | 45 | 46 | 47 | ``` 48 | 49 | ### Unique virtual block 50 | 51 | ```vue 52 | 53 | 54 | 55 | 56 | 57 | 58 | ``` 59 | ### Props 60 | | Name | Type | Default | Description | 61 | |------------------|---------------|---------|--------------| 62 | | data | Array | - | 必填项,列表中数组数据 | 63 | | height | Number | - | 虚拟滚动区域的高度 | 64 | | flxedBlockHeight | Number | - | 每一个列表Item的高度 | 65 | | pageMode | Boolean | true | 假定滚动条是在window上还是在指定的虚拟滚动盒子上 | 66 | 67 | ### DataObjet 68 | | Name | Type | Default | Description | 69 | |--------|---------------|---------|-------------------------------------| 70 | | id | String/Number | - | 必填项,虚拟列表渲染的唯一key | 71 | | height | Number | - | 只有当`flxedBlockHeight`没有设定的时候才会使用这个值 | 72 | ### License 73 | MIT -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "virtual-list-scroll", 3 | "version": "1.1.0", 4 | "main": "src/index.js", 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "license": "MIT", 11 | "author": "小小荧", 12 | "description": "一个可以让大量列表渲染无压力的虚拟滚动列表", 13 | "dependencies": { 14 | "core-js": "^3.6.5", 15 | "vue": "^2.7.16" 16 | }, 17 | "homepage": "https://virtual-list-scroll.vercel.app/", 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/xfy196/virtual-list-scroll" 21 | }, 22 | "keywords": ["virtual", "list", "scroll"], 23 | "devDependencies": { 24 | "@vue/cli-plugin-babel": "~4.5.0", 25 | "@vue/cli-plugin-eslint": "~4.5.0", 26 | "@vue/cli-service": "~4.5.0", 27 | "babel-eslint": "^10.1.0", 28 | "eslint": "^6.7.2", 29 | "eslint-plugin-vue": "^6.2.2", 30 | "vue-template-compiler": "^2.7.16" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xfy196/virtual-list-scroll/02ba5986e7e1c3e1903029c70411287ad55f85de/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 12 | We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue. 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | Virtual List Scroll 4 | 5 | 6 | 7 | Data Amount 8 | 9 | 10 | 100 11 | 1000 12 | 10000 13 | 200000 14 | 500000 15 | 16 | 17 | 18 | 19 | Page Mode 20 | 21 | 22 | 23 | 24 | 25 | Fixed Block Height 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | {{data.id}} 34 | 35 | 36 | 37 | 38 | 39 | 40 | 93 | 94 | -------------------------------------------------------------------------------- /src/VirtualListScroll/index.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import VirtualListScroll from "./VirtualListScroll" 2 | const plugin = { 3 | install(Vue) { 4 | Vue.component("VirtualListScroll", VirtualListScroll) 5 | } 6 | } 7 | export default plugin -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | new Vue({ 7 | render: h => h(App), 8 | }).$mount('#app') 9 | --------------------------------------------------------------------------------