小小白萝 2024-08-20 16:32 采纳率: 50%
浏览 202
已结题

uniapp移动app使用nvue页面中recycle-list组件写聊天列表,反复出现闪退问题

uniapp移动app使用nvue页面中recycle-list组件写聊天列表,反复出现闪退问题,点击聊天,明明点了一个,可是其他聊天的未读数也会被消除,上下滑经常出现部分内容消失,或者乱码问题,或者头像背景色失效,

img


img

if ((oneType && that.currentIndex == 0) || (twoType && that.currentIndex == 1) ||
                            (threeType && that.currentIndex == 2) || (fourType && that.currentIndex ==
                                3) ||
                            (fiveType && that.currentIndex == 4)) {
                            // console.log('更新当前列表数据');
                            that.chatListType[that.currentIndex].num = that.chatListType[that.currentIndex]
                                .num + 1;
                            if (showIndex > -1) {
                                that.showDialogList.splice(showIndex, 1);
                                that.currentDialogIds.splice(showIndex, 1);
                            }
                            that.showDialogList.splice(0, 0, currtentNewItem);
                            that.currentDialogIds.unshift(payload.dialogId + "");
                        } else {
                            let otherIndex = typeList.indexOf(true);
                            // console.log('otherIndex', otherIndex);
                            that.chatListType[otherIndex].num = that.chatListType[otherIndex]
                                .num + 1;
                        }

<recycle-list for="(i, index) in showDialogList" class="back">
            <cell-slot class="">
                <transition name="fade">
                    <view class="r-list-box flex-row">
                        <div class="r-realname-box" :style="{backgroundColor:i.tag999?'#'+i.tag999:{orange}}"
                            @longpress="onLongPress" @touchstart="touchStart(i,index)">
                            <text class="r-realname" v-if="i.realname">
                                {{i.realname}}
                            </text>
                        </div>
                        <view class="posi-read">
                            <view class="r-noread-box n-flex-center" v-if="i.num>0">
                                <text class="r-noread">{{i.num}}</text>
                            </view>
                        </view>
                        <view class="r-box-right" @touchend="navChat(i,index)"
                            :style="{width:i.rightWidth?i.rightWidth+'px':{}}" @appear="onappear(i,index)">
                            <view class="n-just-bet">
                                <view class="" style="" :style="{width:i.rightTitleWidth?i.rightTitleWidth+'px':{}}">
                                    <text class="r-content-t n-omit" v-if="i.title">{{i.title}}</text>
                                </view>
                                <view class="">
                                    <text class="r-content-tag r-color-grey" style="text-align: right;"
                                        v-if="i.time">{{i.time}}</text>
                                </view>
                            </view>
                            <view class="flex-row r-padd">
                                <text class="r-content-tag r-color-red r-padd-left" v-if="i.status===1">置顶</text>
                                <text class="r-content-tag r-color-orange r-padd-left"
                                    v-if="i.tag1.planStr">{{i.tag1.planStr}}</text>

                                <text class="r-content-tag r-color-grey r-padd-left" v-if="i.tags[0]">
                                    {{i.tags[0]}}
                                </text>
                                <text class="r-content-tag r-color-grey r-padd-left" v-if="i.tags[1]">
                                    {{i.tags[1]}}
                                </text>
                                <text class="r-content-tag r-color-grey r-padd-left" v-if="i.tags[2]">
                                    {{i.tags[2]}}
                                </text>
                                <text class="r-content-tag r-color-grey r-padd-left" v-if="i.tags[3]">
                                    {{i.tags[3]}}
                                </text>
                                <text class="r-content-tag r-color-grey" v-if="i.tags[4]">
                                    ...
                                </text>
                                <text class="r-content-tag r-color-red r-padd-left"
                                    v-if="i.inspectDay">{{i.inspectDay}}无指标</text>
                            </view>
                            <view class="n-just-bet">
                                <view class="" v-if="i.lastMsgTimeStr"
                                    :style="{width:i.rightContentWidth?i.rightContentWidth+'px':{}}">
                                    <text class="r-content-tag r-padd r-color-grey n-omit"
                                        v-if="i.nickname||i.desc">{{i.nickname}}:{{i.desc}}</text>
                                </view>
                                <view class="" :style="{width:i.rightWidth?i.rightWidth+'px':{}}" v-else>
                                    <text class="r-content-tag r-padd r-color-grey n-omit"
                                        v-if="i.nickname||i.desc">{{i.nickname}}:{{i.desc}}</text>
                                </view>
                                <view class=" flex-row flex-ali-center">
                                    <text class="r-content-tag r-color-grey"
                                        v-if="i.lastMsgTimeStr">回复:{{i.lastMsgTimeStr}}</text>
                                </view>
                            </view>
                        </view>
                    </view>
                </transition>
            </cell-slot>
        </recycle-list>


闪退问题log文件:

PRODUCT:SEA-AL10
RADIO:unknown
SERIAL:unknown
SUPPORTED_32_BIT_ABIS:[Ljava.lang.String;@875db50
SUPPORTED_64_BIT_ABIS:[Ljava.lang.String;@2e0f149
SUPPORTED_ABIS:[Ljava.lang.String;@ac12a4e
TAGS:release-keys
TIME:1706676915000
TYPE:user
UNKNOWN:unknown
USER:test
java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$AsyncFutureTask.done(AsyncTask.java:429)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:932)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.taobao.weex.ui.component.WXComponent.updateDemission(float, float, float, float, float, float)' on a null object reference
    at com.taobao.weex.ui.component.binding.Statements.copyComponentTree(Unknown Source:55)
    at com.taobao.weex.ui.component.binding.Statements.copyComponentTree(Unknown Source:4)
    at com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList.copyComponentFromSourceCell(Unknown Source:3)
    at com.taobao.weex.ui.component.list.template.AsyncCellLoadTask.doInBackground(Unknown Source:43)
    at com.taobao.weex.ui.component.list.template.AsyncCellLoadTask.doInBackground(Unknown Source:2)
    at android.os.AsyncTask$3.call(AsyncTask.java:389)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 3 more
  • 写回答

25条回答 默认 最新

  • 杨同学* 2024-08-20 17:23
    关注
    获得2.00元问题酬金

    该回答引用ChatGPT4o及杨同学*共同作答, 如有帮助,还请采纳。
    关于你在 uni-app 中使用 nvue 页面的 recycle-list 组件时遇到的闪退问题,这可能涉及多个方面的原因,包括代码中的逻辑错误、数据绑定问题,以及可能的 nvue 本身的 Bug。以下是一些可能的解决方案和调试建议:

    1. 检查数据绑定和逻辑

    • 在你提供的代码片段中,确保数据的绑定是正确的,特别是 i.tag999i.tags 等字段。你可以尝试在绑定数据时添加默认值,以避免出现 undefinednull 引发的错误。
    • 例如:{{i.realname || ''}} 或者 :style="{backgroundColor:i.tag999?'#'+i.tag999:'#defaultColor'}"

    2. 逐步调试

    • 日志输出:在重要的逻辑位置添加日志输出(例如 console.log()),检查数据是否正确传递和处理。
    • 简化测试:尝试简化 recycle-list 的内容,例如移除一些非关键的部分,看看是否还会出现崩溃,从而缩小问题的范围。

    3. 使用 Weex Inspector

    • 你可以使用 Weex Devtools 或 Weex Inspector 来调试 nvue 页面。这个工具可以帮助你检查组件树、数据绑定和样式应用的情况,可能有助于发现问题。

    4. 更新/修复 Bug

    • 确保你使用的是 uni-app 的最新版本,nvue 以及 Weex 相关的依赖可能有修复此类问题的更新。
    • 如果你发现这是 nvueWeex 自身的 Bug,可以考虑在 dcloud 官方的论坛或 GitHub 上报告问题,并关注相关的修复。

    5. 检查异步操作

    • 你的错误日志中提到的 AsyncTask 异常可能与异步加载数据或组件渲染有关。确保所有异步操作都能正确处理错误,避免 null 引用等问题。

    6. 缓存问题

    • 有时,recycle-list 的问题与缓存有关。尝试清理应用缓存,或者在调试模式下禁用缓存,看看问题是否依旧存在。

    7. 替代方案

    • 如果问题持续无法解决,考虑使用 scroll-view 等其他组件替代 recycle-list,尤其是在内容并不非常庞大的情况下。

    闪退问题具体分析

    从日志中,可以看出这个 NullPointerException 是由于试图在一个空对象上调用方法引起的。此错误通常是因为 Weex 框架中的组件树或模板在渲染时出现问题。WXRecyclerTemplateList 组件中调用了 copyComponentFromSourceCell 方法时,组件树可能没有正确构建,导致了这个问题。

    总结

    可以尝试按照上述建议进行调试和修改。如果问题持续存在,考虑向 uni-appWeex 官方社区反馈,以获取更多帮助。

    评论

报告相同问题?

问题事件

  • 系统已结题 8月28日
  • 赞助了问题酬金100元 8月20日
  • 创建了问题 8月20日