mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
1.5 KiB
1.5 KiB
Waterfall
Note: Waterfall is deprecated and no longer maintained, please use the List component instead.
Install
Global registration
import Vue from 'vue';
import { Waterfall } from 'vant';
Vue.use(Waterfall);
Local registration
If you just watch to use Waterfall
in a component, you can register the directive in the component.
import { Waterfall } from 'vant';
export default {
directives: {
WaterfallLower: Waterfall('lower'),
WaterfallUpper: Waterfall('upper')
}
};
Usage
Basic Usage
<ul
v-waterfall-lower="loadMore"
waterfall-disabled="disabled"
waterfall-offset="400"
>
<li v-for="item in list">{{ item }}</li>
</ul>
export default {
data() {
return {
list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
disabled: false
};
},
directives: {
WaterfallLower: Waterfall('lower')
},
methods: {
loadMore() {
this.disabled = true;
setTimeout(() => {
for (let i = 0; i < 5; i++) {
this.list.push(this.list.length);
}
this.disabled = false;
}, 200);
}
}
};
API
Attribute | Description | Type | Default |
---|---|---|---|
v-waterfall-lower | Function to trigger when scroll to bottom | Function |
- |
v-waterfall-upper | Function to trigger when scroll to top | Function |
- |
waterfall-disabled | Key of the property to control disable status in instance | String |
- |
waterfall-offset | Offset to trigger callback function | Number |
300 |