B2 Pro 移动端我的关注显示空白错误修复

B2 Pro 移动端我的关注显示空白错误修复,具体错误显示为打开会员中心的我的关注,会显示空白,

B2 Pro 移动端我的关注显示空白错误修复

错误类型为Vue生命周期钩子调用错误

原函数文件位于代码文件中my/follow.vue

<script> export default{ data(){ return { loadLocked:false, loadmore:'waiting', paged:1, dataList:'', locked:false } }, onShow() { if(!this.$store.state.token){ uni.navigateTo({ url: '/global/login' }) return } this.getData(1) }, computed:{ userData(){ return this.$store.state.userData } }, onReachBottom(){ this.getCurrentUserInfo().then(()=>{ this.getPost() }) }, onPullDownRefresh() { this.paged = 1 this.getPost() }, onLoad() { }, methods:{ getPost(paged){ if(this.loadLocked){ return } if(this.paged > 1){ this.loadmore = true } if(paged){ this.paged = paged } uni.request({ method:"post", url: this.$store.state.restUrlNormal+'getAuthorFollowing', header: this.$store.state.headerToken, data:{ user_id: this.userData.id, number: 26, post_paged: this.paged, paged: this.paged, json:true }, success: (res) => { if(this.paged == 1){ if(res.data.data.length > 0){ this.dataList = res.data.data }else{ this.dataList = 'empty' } }else{ if(res.data.data.length > 0){ this.dataList = this.dataList.concat(res.data.data) }else{ this.loadmore = false this.loadLocked = true } } this.paged++ uni.stopPullDownRefresh(); }, }) }, follow(id,i){ if(this.locked) return this.locked = true uni.request({ method:"post", url: this.$store.state.restUrlNormal+'AuthorFollow', header: this.$store.state.headerToken, data:{ user_id:id }, success: (res) => { this.locked = false if(res.data){ this.$set(this.dataList[i],'followed',false) }else{ this.$set(this.dataList[i],'followed',true) } } }) } } } </script>

这个错误提示表明你在 onShow 生命周期钩子中调用了 this.getData(1),但是在 methods 中并没有定义 getData 方法,而是定义了 getPost 方法。

要解决这个问题,你有两个选择:

  1. 将 onShow 中的 this.getData(1) 改为 this.getPost(1)
  2. 或者在 methods 中添加 getData 方法(如果这是你实际需要的)

根据代码上下文,看起来你应该是想调用 getPost 方法,所以第一种解决方案更合适:

onShow() {
    if(!this.$store.state.token){
        uni.navigateTo({
            url: '/global/login'
        })
        return
    }
    this.getPost(1)  // 这里改为调用 getPost 而不是 getData
},

B2 Pro 移动端我的关注显示空白错误修复

按以上修改就可以修复了。

给TA赏糖
共{{data.count}}人
人已赏糖
技术分享

突破Nginx中文PDF预览瓶颈:Nginx配置文件与Script脚本解法

2025-3-11 7:58:34

技术分享

Linux数据库命令大全

2025-8-5 1:42:15

0 条回复 A文章作者 M管理员
技术宅评论
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索