| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <template>
- <!-- 移动端上拉加载更多 -->
- </template>
- <script>
- export default {
- data () {
- return {
- isSearchingMore: false
- }
- },
- props: ['searchMore', 'allPage', 'page'],
- watch: {
- 'searchMore': {
- handler: function (val) {
- this.isSearchingMore = val
- }
- }
- },
- mounted () {
- let _this = this
- _this.$nextTick(function () {
- window.addEventListener('scroll', function () {
- _this.scroll()
- }, false)
- })
- },
- methods: {
- scroll: function () {
- let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
- if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.page < this.allPage) {
- this.getMore()
- }
- },
- getMore: function () {
- if (!this.isSearchingMore) {
- this.isSearchingMore = true
- this.$emit('pullUpAction')
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .loading {
- text-align: center;
- background: #fff;
- >img {
- width: .64rem;
- height: .64rem;
- margin: .2rem 0;
- }
- }
- </style>
|