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.
PHP中文网
PHP中文网 2017-05-19 10:38:58
0
1
610

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中文网

认证0级讲师

reply all(1)
習慣沉默

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!