Skip to content

Commit 178e056

Browse files
feat: ✨ Loadmore提供loadingProps属性用于自定义loading样式
1 parent 66fff60 commit 178e056

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

docs/component/loadmore.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ image {
126126
| loading-text | 加载提示文案 | string | - | 加载中... | - |
127127
| finished-text | 全部加载完的提示文案 | string | - | 没有更多了 | - |
128128
| error-text | 加载失败的提示文案 | string | - | 加载失败,点击重试 | - |
129+
| loading-props | loading加载组件属性| `Partial<LoadingProps>` | - | - | $LOWEST_VERSION$ |
130+
131+
#### LoadingProps
132+
参见[LoadingProps](/component/loading.html#attributes)
129133

130134
## Events
131135

src/uni_modules/wot-design-uni/components/wd-loadmore/types.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { PropType } from 'vue'
2-
import { baseProps, makeStringProp } from '../common/props'
2+
import { baseProps } from '../common/props'
3+
import type { LoadingProps } from '../wd-loading/types'
34

45
export type LoadMoreState = 'loading' | 'error' | 'finished'
56

@@ -20,5 +21,10 @@ export const loadmoreProps = {
2021
/**
2122
* 加载失败的提示文案
2223
*/
23-
errorText: String
24+
errorText: String,
25+
/**
26+
* 加载中loading组件的属性
27+
* 参考loading组件
28+
*/
29+
loadingProps: Object as PropType<Partial<LoadingProps>>
2430
}

src/uni_modules/wot-design-uni/components/wd-loadmore/wd-loadmore.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<!--
2+
* @Author: weisheng
3+
* @Date: 2024-11-09 12:35:25
4+
* @LastEditTime: 2024-11-09 15:01:32
5+
* @LastEditors: weisheng
6+
* @Description:
7+
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-loadmore/wd-loadmore.vue
8+
* 记得注释
9+
-->
110
<template>
211
<view :class="['wd-loadmore', customClass]" :style="customStyle" @click="reload">
312
<wd-divider v-if="state === 'finished'">{{ finishedText || translate('finished') }}</wd-divider>
@@ -7,7 +16,7 @@
716
<wd-icon name="refresh" custom-class="wd-loadmore__refresh" />
817
</block>
918
<block v-if="state === 'loading'">
10-
<wd-loading custom-class="wd-loadmore__loading" />
19+
<wd-loading v-bind="customLoadingProps" />
1120
<text class="wd-loadmore__text">{{ loadingText || translate('loading') }}</text>
1221
</block>
1322
</view>
@@ -28,9 +37,17 @@ export default {
2837
import wdDivider from '../wd-divider/wd-divider.vue'
2938
import wdLoading from '../wd-loading/wd-loading.vue'
3039
import wdIcon from '../wd-icon/wd-icon.vue'
31-
import { ref } from 'vue'
40+
import { computed, ref } from 'vue'
3241
import { useTranslate } from '../composables/useTranslate'
3342
import { loadmoreProps, type LoadMoreState } from './types'
43+
import type { LoadingProps } from '../wd-loading/types'
44+
import { isDef, isUndefined, omitBy } from '../common/util'
45+
46+
const customLoadingProps = computed(() => {
47+
const loadingProps: Partial<LoadingProps> = isDef(props.loadingProps) ? omitBy(props.loadingProps, isUndefined) : {}
48+
loadingProps.customClass = `wd-loadmore__loading ${loadingProps.customClass || ''}`
49+
return loadingProps
50+
})
3451
3552
const props = defineProps(loadmoreProps)
3653
const emit = defineEmits(['reload'])

0 commit comments

Comments
 (0)