您好,登錄后才能下訂單哦!
前幾天小項目,沒考慮周全,讓后端改接口,改成數組中包含對象中包含數組的形式,后來越琢磨越不對,后臺把所有數據放在了一個對象里,我拿彈窗數據不好拿,索性又改了回來,把后端折騰夠嗆,自己也折騰夠嗆,發上來,以示警戒
改前拿數據
<div class='your-container'> <div class="sortText"> <div>綜合排序</div> <div class="sortHot" @click="mostHot"><p>最熱</p><div class="sortImg"><img src="../../assets/imgs/mosthot.png" alt=""></div></div> <div class="sortHot" @click="mostNew"><p>最新</p><div class="sortImg"><img src="../../assets/imgs/mostview.png" alt=""></div></div> <div class="adhibition" @click="adhibition(0)">應用</div> <div class="adhibition" @click="adhibition(1)">算法</div> </div> <!-- bind your configurations --> <vue-scroll :ops="ops"> <div class='your-content'> <ul class="listBox" @handle-resize="handleResize"> <li v-for="(item,index) in list" :key="index" class="lis"> <div class="listIcon"> <img src="../../assets/imgs/jicon.png" alt=""> </div> <div class="listText"> <div class="names">{{item.ename}}</div> <div class="introduce"> {{item.introduce}} <div class="details" @click="detailsClick">詳情</div> </div> <div class="spans" v-for='(value,key,idx) in item' :key='idx'> <p v-if='Object.prototype.toString.call(value).slice(8,-1) == "Array"'><span>{{value[0]}}:</span><span class="lastname">{{value[1]}}</span></p> </div> <div class="lineBox"> <div class="lineoneBox"><img src="../../assets/imgs/line1.png" alt=""></div> <div class="whiteBox"></div> </div> </div> </li> </ul> </div> </vue-scroll> <detailsPopUp @manage="manshow" v-if="manageshow"/> </div>
改后
<div class='your-container'> <div class="sortText"> <div>綜合排序</div> <div class="sortHot" @click="mostHot"><p>最熱</p><div class="sortImg"><img src="../../assets/imgs/mosthot.png" alt=""></div></div> <div class="sortHot" @click="mostNew"><p>最新</p><div class="sortImg"><img src="../../assets/imgs/mostview.png" alt=""></div></div> <div class="adhibition" @click="adhibition(0)">應用</div> <div class="adhibition" @click="adhibition(1)">算法</div> </div> <!-- bind your configurations --> <vue-scroll :ops="ops"> <div class='your-content'> <ul class="listBox" @handle-resize="handleResize"> <li v-for="(item,index) in list" :key="index" class="lis"> <div class="listIcon"> <img src="../../assets/imgs/jicon.png" alt=""> </div> <div class="listText"> <div class="names">{{item.ename}}</div> <div class="introduce"> {{item.introduce}} <div class="details" @click="detailsClick(item.version,item.trade,item.interfaceClassName)">詳情</div> </div> <div class="spans" > <p><span>提供廠商:</span><span class="lastname">{{item.manufacturerName}}</span></p> <p v-show="item.type==0"><span>使用總次數:</span><span class="lastname">{{item.totalCount}}</span></p> <p v-show="item.type==0"><span>安裝時間:</span><span class="lastname">{{item.createTime}}</span></p> <p v-show="item.type==1"><span>平均響應時間:</span><span class="lastname">{{item.avgResponseTime}}</span></p> <p v-show="item.type==1"><span>準確率:</span><span class="lastname">{{item.accuracyRate}}%</span></p> <p v-show="item.type==0"><span>占用內存:</span><span class="lastname">{{item.memory}}</span></p> </div> <div class="lineBox"> <div class="lineoneBox"><img src="../../assets/imgs/line1.png" alt=""></div> <div class="whiteBox"></div> </div> </div> </li> </ul> </div> </vue-scroll> <detailsPopUp @manage="manshow" v-if="manageshow" :scrollDataverson="detailsverson" :scrollDatatrade="detailstrade" :scrollDatainterfaceClassName="detailsinterfaceClassName"/> </div>
以上這篇vue遍歷對象中的數組取值示例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。