在VUEJS 3应用中错误的情况下,如何获取更多信息?

发布于 2025-02-01 19:47:03 字数 9272 浏览 0 评论 0原文

在Vuejs 3应用程序中,在更改服务器脚本后,我会出现错误

app.js:30792 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')

,在我的控制台中,我看到了: https://prnt.sc/tdeypqlyzioy

单击这些链接,很难获得善良的错误/错误/实际上我不得不发表评论 代码块以发现该错误是由

{{ todo.user.id }}

SI LINE触发的,我必须用

{{todo.creator_username}}

更新它,以反映我的服务器脚本更改。

我的Chrome上安装了Vue DevTools,但我找不到它是否提供了一些添加信息 帮助解决这个问题。

是否有一些有关此类调试/获取更多信息的工具?

页面来源:

<template>

    <div class="flex justify-center w-full d1">
        <div class="block p-6 rounded-lg shadow-lg bg-white max-w-lg">
            <h5 class="text-gray-900 text-xl leading-tight font-medium mb-2">
                {{ todo.id }}=>{{ todo.status }}=>{{ todo.name }}
            </h5>
            <h5 class="text-gray-900 text-sm leading-tight font-medium mb-2">
                By {{ todo.user_id }}=>
                {{ todo.creator_username }} on
                {{ todo.created_at_formatted }}, <strong>{{ todo.status_label }}</strong>
            </h5>
            <h5 class="text-gray-900 text-sm leading-tight font-medium mb-2">
                <strong>{{ todo.uncompleted_todo_tasks_count }} uncompleted task{{pluralize(todo.uncompleted_todo_tasks_count, '', 's') }}</strong> from {{ todo.todo_tasks_count }}
            </h5>
            <p class="text-gray-700 text-base mb-4" v-html="todo.description">
            </p>

            <div class="flex justify-center">
                <div class="bg-white rounded-lg border border-gray-200 w-96 text-gray-900">
                    <template v-for="(nextTodoTask, index) in todo.todoTasks" :key="nextTodoTask.id">

                        <div class="flex justify-center">
                            <ul class="bg-white rounded-lg border border-gray-200 w-96 text-gray-900">
                                <li
                                    v-if="nextTodoTask.status === 'D'"
                                    class="px-6 py-2 border-b border-gray-200 w-full bg-gray-200 rounded-t-lg text-gray-400 cursor-default"
                                >
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ getDictionaryLabel(nextTodoTask.status, settingsTodoTaskStatusLabels ) }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>
                                </li>

                                <li
                                    v-if="nextTodoTask.status === 'C'"
                                    class="px-6 py-2 border-b border-gray-200 w-full bg-blue-200 text-white">
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ nextTodoTask.status_label }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>

                                    <JetSecondaryButton @click="uncompleteTodoTask(todo.id, nextTodoTask.id, index)">
                                        Uncomplete
                                    </JetSecondaryButton>
                                    <JetSecondaryButton @click="disableTodoTask(todo.id, nextTodoTask.id, index)" class="ml-4">
                                        Disable
                                    </JetSecondaryButton>
                                    <div v-show="is_data_loading" class="ml-2 form_processing"></div>
                                </li>

                                <li
                                    v-if="nextTodoTask.status === 'U'"
                                    class="px-6 py-2 border-b border-gray-200 w-full bg-blue-200 text-white">
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ nextTodoTask.status_label }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>

                                    <JetSecondaryButton @click="uncompleteTodoTask(todo.id, nextTodoTask.id, index)">
                                        Uncomplete
                                    </JetSecondaryButton>
                                    <JetSecondaryButton @click="disableTodoTask(todo.id, nextTodoTask.id, index)" class="ml-4">
                                        Disable
                                    </JetSecondaryButton>
                                    <div v-show="is_data_loading" class="ml-2 form_processing"></div>
                                </li>

                                <li
                                    v-if="nextTodoTask.status === 'A'"
                                    class="px-6 py-2 border-b border-gray-200 w-full">
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}<br>

                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ nextTodoTask.status_label }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4" v-if="nextTodoTask.is_task_expired">
                                        <i :class="getHeaderIcon('error')"
                                           title="You can not make any operations on this task"
                                           class="action_icon icon_right_text_margin"></i>
                                        Task is expired
                                    </p>
                                    <p class="text-gray-700 text-base mb-4" v-if="!nextTodoTask.is_task_expired">
                                        Deadline at {{ nextTodoTask.deadline_formatted }}
                                    </p>

                                    <JetButton @click="completeTodoTask(todo.id, nextTodoTask.id, index)"
                                               :class="{ 'opacity-25': is_data_loading }" :disabled="is_data_loading"
                                               v-if="!nextTodoTask.is_task_expired">
                                        Complete
                                    </JetButton>
                                    <JetSecondaryButton @click="disableTodoTask(todo.id, nextTodoTask.id, index)"
                                                        class="ml-4">
                                        Disable
                                    </JetSecondaryButton>

                                </li>
                            </ul>
                        </div>

                    </template>

                </div>
            </div>


        </div>
    </div>

</template>

谢谢!

In vuejs 3 app after changes of servers scripts I got error

app.js:30792 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')

and in my console I see:
https://prnt.sc/TdEYpqlyZioY

Clicking on these links it is rather difficult to get kind/line of error and actually I had to comment
blocks of code to find that this error was triggered by line

{{ todo.user.id }}

si I had to update it with

{{ todo.creator_username }}

reflecting my changes of servers script.

I have Vue Devtools installed on my Chrome, but I did not find if it provides some additive information
helping to salve this issue.

Are there some tools for such debugging/getting more info as for the error ?

Page source :

<template>

    <div class="flex justify-center w-full d1">
        <div class="block p-6 rounded-lg shadow-lg bg-white max-w-lg">
            <h5 class="text-gray-900 text-xl leading-tight font-medium mb-2">
                {{ todo.id }}=>{{ todo.status }}=>{{ todo.name }}
            </h5>
            <h5 class="text-gray-900 text-sm leading-tight font-medium mb-2">
                By {{ todo.user_id }}=>
                {{ todo.creator_username }} on
                {{ todo.created_at_formatted }}, <strong>{{ todo.status_label }}</strong>
            </h5>
            <h5 class="text-gray-900 text-sm leading-tight font-medium mb-2">
                <strong>{{ todo.uncompleted_todo_tasks_count }} uncompleted task{{pluralize(todo.uncompleted_todo_tasks_count, '', 's') }}</strong> from {{ todo.todo_tasks_count }}
            </h5>
            <p class="text-gray-700 text-base mb-4" v-html="todo.description">
            </p>

            <div class="flex justify-center">
                <div class="bg-white rounded-lg border border-gray-200 w-96 text-gray-900">
                    <template v-for="(nextTodoTask, index) in todo.todoTasks" :key="nextTodoTask.id">

                        <div class="flex justify-center">
                            <ul class="bg-white rounded-lg border border-gray-200 w-96 text-gray-900">
                                <li
                                    v-if="nextTodoTask.status === 'D'"
                                    class="px-6 py-2 border-b border-gray-200 w-full bg-gray-200 rounded-t-lg text-gray-400 cursor-default"
                                >
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ getDictionaryLabel(nextTodoTask.status, settingsTodoTaskStatusLabels ) }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>
                                </li>

                                <li
                                    v-if="nextTodoTask.status === 'C'"
                                    class="px-6 py-2 border-b border-gray-200 w-full bg-blue-200 text-white">
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ nextTodoTask.status_label }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>

                                    <JetSecondaryButton @click="uncompleteTodoTask(todo.id, nextTodoTask.id, index)">
                                        Uncomplete
                                    </JetSecondaryButton>
                                    <JetSecondaryButton @click="disableTodoTask(todo.id, nextTodoTask.id, index)" class="ml-4">
                                        Disable
                                    </JetSecondaryButton>
                                    <div v-show="is_data_loading" class="ml-2 form_processing"></div>
                                </li>

                                <li
                                    v-if="nextTodoTask.status === 'U'"
                                    class="px-6 py-2 border-b border-gray-200 w-full bg-blue-200 text-white">
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ nextTodoTask.status_label }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>

                                    <JetSecondaryButton @click="uncompleteTodoTask(todo.id, nextTodoTask.id, index)">
                                        Uncomplete
                                    </JetSecondaryButton>
                                    <JetSecondaryButton @click="disableTodoTask(todo.id, nextTodoTask.id, index)" class="ml-4">
                                        Disable
                                    </JetSecondaryButton>
                                    <div v-show="is_data_loading" class="ml-2 form_processing"></div>
                                </li>

                                <li
                                    v-if="nextTodoTask.status === 'A'"
                                    class="px-6 py-2 border-b border-gray-200 w-full">
                                    <p class="text-gray-700 text-base mb-4">
                                        <i :class="getHeaderIcon('info')" :title="nextTodoTask.description"
                                           class="action_icon icon_right_text_margin"></i>
                                        {{ nextTodoTask.name }}<br>

                                    </p>

                                    <p class="text-gray-700 text-base mb-4">
                                        <strong>{{ nextTodoTask.status_label }}</strong>, created at {{
                                            nextTodoTask.created_at_formatted
                                        }}
                                    </p>

                                    <p class="text-gray-700 text-base mb-4" v-if="nextTodoTask.is_task_expired">
                                        <i :class="getHeaderIcon('error')"
                                           title="You can not make any operations on this task"
                                           class="action_icon icon_right_text_margin"></i>
                                        Task is expired
                                    </p>
                                    <p class="text-gray-700 text-base mb-4" v-if="!nextTodoTask.is_task_expired">
                                        Deadline at {{ nextTodoTask.deadline_formatted }}
                                    </p>

                                    <JetButton @click="completeTodoTask(todo.id, nextTodoTask.id, index)"
                                               :class="{ 'opacity-25': is_data_loading }" :disabled="is_data_loading"
                                               v-if="!nextTodoTask.is_task_expired">
                                        Complete
                                    </JetButton>
                                    <JetSecondaryButton @click="disableTodoTask(todo.id, nextTodoTask.id, index)"
                                                        class="ml-4">
                                        Disable
                                    </JetSecondaryButton>

                                </li>
                            </ul>
                        </div>

                    </template>

                </div>
            </div>


        </div>
    </div>

</template>

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文