随笔-vue

  • 2017-09-06
  • 271
  • 2

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”:[]是这样的
正常下 可以这么写

  
  • id是:{{item.process[0].id}}

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

  • id是:{{item.process[0].id}}

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

评论

    • ytu回复

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

- 友情链接 - Theme by Qzhai