【问题标题】:How to make an array of objects from object array in vueJs?如何从 vueJs 中的对象数组制作对象数组?
【发布时间】:2021-05-31 03:52:12
【问题描述】:

我有一个如下的对象数组

但是,我需要展示

  • 电子邮件:电子邮件 muss eine .....
  • 电话:电话号码员 ...

如何在 javascript 中做到这一点?实际上我需要在 VueJs 中使用它。

【问题讨论】:

标签: javascript vue.js


【解决方案1】:

从您从道具收到的屏幕截图中,我们可以在模板中执行此操作:

<template>
  <div class="errors">
    {{  failureReasons.email ? failureReasons.email[0] }}
  </div>
</template>

如果您想将所有错误放入一个数组中(例如['Email mus...', 'Telefon ...']),您可以这样做:

<template>
  <ul>
   <li v-for="error in Object.keys(failureReasons).map(key => failureReasons[key][0])"> {{ error}} </li>
  <ul>
</template>

【讨论】:

    猜你喜欢
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 2022-07-22
    • 2014-02-20
    • 1970-01-01
    相关资源
    最近更新 更多