随笔-vue

1.vue中v-for循环数据的问题

[
{
  "id":"179","pname":"新的流程","rname":"admin","subname":"丹的","user":"","lid":"79","ifread":"1","attachment":"","content":"123213213","position":"1","rid":"2147483647","state":"1",
  "process":[
             {"id":"79","pid":"","pname":"新的流程","nodeArray":"ui-总经理-前端-app","start":"ui"}]},
{
  "id":"198","pname":"新的流程","rname":"admin","subname":"丹的","user":"","lid":"79","ifread":"0","attachment":"","content":"21312","position":"2","rid":"2147483647","state":"0",
  "process":[
             {"id":"79","pid":"","pname":"新的流程","nodeArray":"ui-总经理-前端-app","start":"ui"}]},
{
  "id":"199","pname":"新的流程","rname":"admin","subname":"丹的","user":"","lid":"79","ifread":"0","attachment":"","content":"ok","position":"2","rid":"2147483647","state":"0",
  "process":[
            {"id":"79","pid":"","pname":"新的流程","nodeArray":"ui-总经理-前端-app","start":"ui"}]

当有这样的数据的时候正常情况是没问题,可是没准后台的数据传给你就少这个少那个,比如:
某一个 "process":[]是这样的
正常下 可以这么写

  

这样就会报错的,应为item.process[0]已经有问题了,在这个空值下找id,当然会报错,
所以这时候就需要


总结
其实简单来说这也是vue的一个生命周期的问题,render的问题。

点赞
  1. 说道:

    😃😃😃😃

    1. ytu说道:

      (#^.^#),有你们,我才有动力写下去!

发表评论

电子邮件地址不会被公开。 必填项已用*标注