【问题标题】:VueJS (InertiaJS) + Laravel 8 displaying multiple inputs errorsVueJS (InertiaJS) + Laravel 8 显示多个输入错误
【发布时间】:2021-01-07 02:51:17
【问题描述】:

我正在尝试显示我的多个输入错误。

我有一个多集输入表单。每一个都有一个标题和描述。

我可以显示其他错误 + 数组错误(1 ep min 和 15 ep max)

但我无法在情节数组中循环。

VueJS(通过 Vue 工具)向我显示正确的错误,例如:errors.episodes.0.description: 0: Episodes.0.description 字段是必需的。

但是当我想遍历 errors.episodes[index].description 时,VueJS 显示:
[Vue warn]: Error in render: "TypeError: can't access property 0, _vm.$ page.errors.episodes 未定义”

我试过了

<div class="text-red-600" v-if="$page.errors.episodes[index].description">
    {{ $page.errors.episodes[index].description[0] }}
</div>

谢谢你们帮助我

【问题讨论】:

    标签: javascript laravel vue.js validation multiple-input


    【解决方案1】:

    在vue中访问$page来做这个

    <div class="text-red-600" v-if="this.$page.errors.episodes[index].description">
        {{ this.$page.errors.episodes[index].description[0] }}
    </div>
    

    【讨论】:

      【解决方案2】:

      问题解决了,“episodes.0.title”是我必须这样做的完整索引:

      <div class="text-red-600" v-if="$page.errors['episodes.0.title']">{{ $page.errors['episodes.0.title'][0] }}</div>
      

      【讨论】:

        猜你喜欢
        • 2020-02-10
        • 1970-01-01
        • 2021-04-27
        • 1970-01-01
        • 2021-06-25
        • 2021-04-13
        • 1970-01-01
        • 2021-11-02
        • 1970-01-01
        相关资源
        最近更新 更多