mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] List: jsx (#2539)
This commit is contained in:
parent
4c4b44df7b
commit
024defbc23
@ -1,34 +1,11 @@
|
||||
<template>
|
||||
<div :class="b()">
|
||||
<slot />
|
||||
<div
|
||||
v-if="loading"
|
||||
:class="b('loading')"
|
||||
>
|
||||
<slot name="loading">
|
||||
<loading :class="b('loading-icon')" />
|
||||
<span
|
||||
v-text="loadingText || $t('loading')"
|
||||
:class="b('loading-text')"
|
||||
/>
|
||||
</slot>
|
||||
</div>
|
||||
<div
|
||||
v-if="finished && finishedText"
|
||||
v-text="finishedText"
|
||||
:class="b('finished-text')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import create from '../utils/create';
|
||||
import { use } from '../utils';
|
||||
import utils from '../utils/scroll';
|
||||
import Loading from '../loading';
|
||||
import { on, off } from '../utils/event';
|
||||
|
||||
export default create({
|
||||
name: 'list',
|
||||
const [sfc, bem, t] = use('list');
|
||||
|
||||
export default sfc({
|
||||
model: {
|
||||
prop: 'loading'
|
||||
},
|
||||
@ -108,9 +85,7 @@ export default create({
|
||||
reachBottom = scroller.scrollHeight - targetBottom < this.offset;
|
||||
} else {
|
||||
const elBottom =
|
||||
utils.getElementTop(el) -
|
||||
utils.getElementTop(scroller) +
|
||||
utils.getVisibleHeight(el);
|
||||
utils.getElementTop(el) - utils.getElementTop(scroller) + utils.getVisibleHeight(el);
|
||||
reachBottom = elBottom - scrollerHeight < this.offset;
|
||||
}
|
||||
|
||||
@ -128,6 +103,24 @@ export default create({
|
||||
(bind ? on : off)(this.scroller, 'scroll', this.check);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
render(h) {
|
||||
return (
|
||||
<div class={bem()}>
|
||||
{this.$slots.default}
|
||||
{this.loading && (
|
||||
<div class={bem('loading')}>
|
||||
{this.$slots.loading || [
|
||||
<Loading class={bem('loading-icon')} />,
|
||||
<span class={bem('loading-text')}>{this.loadingText || t('loading')}</span>
|
||||
]}
|
||||
</div>
|
||||
)}
|
||||
{this.finished && this.finishedText && (
|
||||
<div class={bem('finished-text')}>{this.finishedText}</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
</script>
|
@ -10,10 +10,7 @@ exports[`renders demo correctly 1`] = `
|
||||
<!---->
|
||||
<!---->
|
||||
</div>
|
||||
<div class="van-list">
|
||||
<!---->
|
||||
<!---->
|
||||
</div>
|
||||
<div class="van-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user