【问题标题】:TypeError: Cannot read properties of undefined (reading 'day')TypeError:无法读取未定义的属性(读取“天”)
【发布时间】:2022-01-11 09:57:24
【问题描述】:
<div class="cont">
    <ul>
        <li v-for="(value, key) in dayappointment.visit" :key="value">
            {{ key }}: {{ value }}
        </li>
    </ul>
    <div class="day">
        <div class="dayboxes">
            {{dayappointment.visit.day}}
        </div>
        <div class="dayboxes">
            {{dayappointment.visit.month}}
        </div>
        <div class="dayboxes">
            {{dayappointment.visit.year}}
        </div>
    </div>
</div>

无序列表显示日、月、年键及其值,但它们在日 div 中以某种方式未定义。

【问题讨论】:

  • 你能显示JSON.stringify(this.dayappointment.visit)的结果吗?
  • {"day":4,"month":"JAN","year":2022}
  • 欢迎分享脚本代码

标签: vue.js vuex


【解决方案1】:
 **somehow what was needed was to iterate the object like this**              
   <div class="day">
            <div v-for="(value) in dayappointment.visit" :key="value" 
             class="dayboxes">
                {{value}}
            </div>
        </div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-26
    • 2021-11-24
    • 2021-12-20
    • 2021-11-27
    • 2022-01-21
    • 2021-12-04
    • 2021-12-09
    • 2021-12-06
    相关资源
    最近更新 更多