uniapp微信小程序组件内能不能触发onraechbottom?

想问一下用uniapp开发的微信小程序 能不能触发onreachbottom 那个底部触发事件? 我是在组件内引用的, 我在别的页面(非组件)可以使用,在组件内不能使用?

  • 这篇博客: uniapp上拉加载的避坑指南中的 一.整个页面的上拉(onReachBottom) 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 注意: 使用scroll-view导致页面级没有滚动,则触底事件不会被触发

    onReachBottom() {
        //当数组里的数据大于等于total的时候,说明数据已经加载完了
        if (this.dataList.length >= this.total) {
            setTimeout(() => {
                this.status = 'noMore'
            }, 1000)
        } else {
            //每次上拉加载的数据比上一次多十个
            this.current++
            this.status = 'loading'
            let that = this
            setTimeout(() => {
                that.getData()
            }, 1000)
    
        }
    },
    methods:{
    	getData(){
            let data={
                current: this.current,
                size: this.size
            }
            uni.request({
                url: 'https://www.example.com/request', //仅为示例,并非真实接口地址。
                data:data,
                header: {
                    'custom-header': 'hello' //自定义请求头信息
                },
                success: (res) => {
                    if (res.success) {
                        //下拉刷新的时候将数组置空
                        if (this.pull) {
                            this.dataList = []
                        }
                        this.total = res.total
                        for (let i = 0; i < res.rows.length; i++) {
                            this.dataList.push(res.rows[i])
                        }
    
                    }
                    this.pull = false
                    this.status = 'noMore'
                }
            });
            
        }
    }