search

Home  >  Q&A  >  body text

javascript - In vue+vuex, the data source obtained using getter can only call the first layer properties, and the second layer will report an error.

Under computed I use

...mapGetters({
    'employeeRenderData': 'getEmployeeRenderData',
})

When calling

value: t.employeeRenderData.employeeSum //可以调到

but

value: t.employeeRenderData.employeeSum.total //就会报错

Cannot read property 'total' of undefined


在template中{{这里面调用也是同样的问题 求大神帮忙}}
PHP中文网PHP中文网2826 days ago657

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-19 10:40:58

    value: t.employeeRenderData.employeeSum && t.employeeRenderData.employeeSum.total

    Maybe employeeSum does not exist when you initially call employeeSum.total, and an error will be reported when you call employeeSum.total. Just make fault tolerance

    reply
    0
  • Cancelreply