Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何循环vuejs中的嵌套数组_Javascript_Arrays_Multidimensional Array_Vue.js - Fatal编程技术网

Javascript 如何循环vuejs中的嵌套数组

Javascript 如何循环vuejs中的嵌套数组,javascript,arrays,multidimensional-array,vue.js,Javascript,Arrays,Multidimensional Array,Vue.js,我有一些多维数组 我的api响应 0: name : "name", address : "address" 0: reciepts : ballance : 10, bill : 101, 1: reciepts : ballance : 12, bill : 101

我有一些多维数组

我的api响应

0:  name : "name",
    address : "address"

        0:
            reciepts : 
                ballance : 10,
                bill : 101, 
        1:  
            reciepts : 
                ballance : 12,
                bill : 101, 

1:  name : "name",
    address : "address"

        0:
            reciepts : 
                ballance : 13,
                bill : 101, 
        1:
            reciepts : 
                ballance : 14,
                bill : 101, 
2:  name : "name",
    address : "address"

        0:
            reciepts : 
                ballance : 15,
                bill : 101, 
        1:
            reciepts : 
                ballance : 16,
                bill : 101, 
我正在将此数据绑定到一个数组

this.reportResults=response.data;
在代码中,我通过这个数组像

<ul>
            <li v-for="report in reportResults"> // this woks fine
                <div class="row " style="background-color: #f4fbee;">
                    <div class="col-md-2">{{report.bill_no}}</div>
                </div>
           </li>
</ul>
  • //这很好用 {{报告。条例草案}
但在这里我想通过接收器循环。所以我就写了

<ul>
                <li v-for="report in reportResults"> // this woks fine
                    <div class="row " style="background-color: #f4fbee;">
                        <div class="col-md-2">{{report.bill_no}}</div>
                    </div>
                   <div class="row" v-for="reciepts in report"> // this print nothing
                       {{reciepts.bill}}
                    </div>
               </li>
    </ul>
  • //这很好用 {{报告。条例草案} //这张照片什么都没有 {{receipts.bill}}

内部循环不打印任何内容。但是如果我在第二个循环中像{{receipts}}一样打印原始数据,它会打印所有数据。那么,我如何在receipts对象中循环呢?

@chrisg已经在评论中给出了答案。然而,由于它隐藏了一点,以下是答案:

<div class="row" v-for="reciept in report.reciepts">{{reciept.bill}}</div>
{{receipt.bill}

请注意,我在访问单个属性时删除了receipt的复数形式。

问题示例中的数据结构有点混乱。
receipts
是数组的键值,还是只是一个数组,其中的对象具有
receipts
键?您能将响应数据发布为JSON吗?我面临内部循环的问题。我想显示收据数组的所有数据。不通过法案_no@ChrisG它不打印任何内容我猜您需要
v-for=“receipts in report.receipts”