12345678910111213141516171819202122232425262728293031323334353637383940 |
- import {
- reactive,
- onMounted,
- getCurrentInstance
- } from 'vue'
- import {
- onReachBottom,
- onShow,
- onPullDownRefresh,
- onReady
- } from '@dcloudio/uni-app'
- export default loadmoreRef => {
- let refs = {}
- const refresh = () => {
- refs[loadmoreRef] && refs[loadmoreRef].refresh()
- }
- onMounted(() => {
- refs = getCurrentInstance().refs
- })
- onPullDownRefresh(() => {
- if (refs[loadmoreRef] && refs[loadmoreRef].pullDownRefresh) {
- refs[loadmoreRef].hasMore = true
- refs[loadmoreRef].query().then(() => uni.stopPullDownRefresh())
- }
- })
- onReachBottom(() => {
- if (refs[loadmoreRef] && refs[loadmoreRef].hasMore) {
- refs[loadmoreRef].query(true)
- }
- })
- return {
- refresh
- }
- }
|