基于Vue开发的下拉刷新组件
npm install ax-scroll -S
- main.js:
import Vue from 'vue' import App from './App.vue' import AxScroll from 'ax-scroll'; Vue.use(AxScroll); new Vue({ el: '#app', render: h => h(App) })
- demo.vue
<ax-scroll @onPullDown="onMockRequset"> <div v-for="item in 20" :key="item" class="list-item"> 卡片{{ item }} </div> </ax-scroll> <script> export default { name: 'app', methods: { onMockRequset({ end }) { setTimeout(() => { end(); // 异步刷新结束后,手动执行停止loading的回调方法 }, 1500); }, }, } </script> <style> body, html { margin: 0; padding: 0; height: 100%; } </style>