vue多次循环操作示例
网络编程 2021-07-04 15:50www.168986.cn编程入门
这篇文章主要介绍了vue多次循环操作,结合实例形式分析了vue.js针对json嵌套数据的多次循环读取操作相关实现技巧,需要的朋友可以参考下
本文实例讲述了vue多次循环操作。分享给大家供大家参考,具体如下
需求有以下一个数组,想将其对象里的信息展示出来,而且还要把对象狼蚁网站SEO优化的数组的具体信息也展示出来。v-for可以实现循环,能否再下一级进行渲染呢?答案是可以的。
list: [{ "scheme_id": "1", "scheme_sn": "2018031416442200001", "scheme_name": "测试支付宝", "type": "", "field_id": "0", "user_id": "5", "mother_id": "0", "content": "测试支付宝", "program_id": "1,2", "status": "1", "range": "1", "obj": "5", "add_time": "2018-03-14 16:44:22", "is_handsel": "2", "atten_del": "", "up_time": null, "obj_phone": "13521121232", "programs": [{ "program_id": "1", "reserve": "99701", "program_name": "测试支付宝1", "price": "0.0100", "sale_num": "200" }, { "program_id": "2", "reserve": "4895", "program_name": "阿萨打算", "price": "0.0200", "sale_num": null }] }, { "scheme_id": "2", "scheme_sn": "2018031416512800002", "scheme_name": "阿散发撒", "type": "", "field_id": "0", "user_id": "5", "mother_id": "0", "content": "阿斯达", "program_id": "2,3", "status": "2", "range": "1", "obj": "5", "add_time": "2018-03-14 16:51:28", "is_handsel": "2", "atten_del": "", "up_time": null, "obj_phone": "13521121232", "programs": [{ "program_id": "2", "reserve": "4895", "program_name": "阿萨打算", "price": "0.0200", "sale_num": null }, { "program_id": "3", "reserve": "10", "program_name": "测试多个程序方案赠送1", "price": "0.0000", "sale_num": null }] }]
HTML部分
<div id="app"> <div v-for ="item in list"> <p>{{item.scheme_sn}}</p> <p v-for="items in item.programs">程序id {{items.program_id}}</p> <p v-for="items in item.programs">程序名称 {{items.program_name}}</p> </div> </div>
先循环大的list 然后再用items in item.programs
去循环对象里面的数组
完整测试示例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>.jb51. vue多次循环</title> <style> { margin: 0; padding: 0; list-style: none; } </style> </head> <body> <div id="app"> <div v-for ="item in list"> <p>{{item.scheme_sn}}</p> <p v-for="items in item.programs">程序id {{items.program_id}}</p> <p v-for="items in item.programs">程序名称 {{items.program_name}}</p> </div> </div> </body> <script src="https://cdn.bootcss./vue/2.4.4/vue.min.js"></script> <script> const app=new Vue({ el:"#app", data:{ list: [{ "scheme_id": "1", "scheme_sn": "2018031416442200001", "scheme_name": "测试支付宝", "type": "", "field_id": "0", "user_id": "5", "mother_id": "0", "content": "测试支付宝", "program_id": "1,2", "status": "1", "range": "1", "obj": "5", "add_time": "2018-03-14 16:44:22", "is_handsel": "2", "atten_del": "", "up_time": null, "obj_phone": "13521121232", "programs": [{ "program_id": "1", "reserve": "99701", "program_name": "测试支付宝1", "price": "0.0100", "sale_num": "200" }, { "program_id": "2", "reserve": "4895", "program_name": "阿萨打算", "price": "0.0200", "sale_num": null }] }, { "scheme_id": "2", "scheme_sn": "2018031416512800002", "scheme_name": "阿散发撒", "type": "", "field_id": "0", "user_id": "5", "mother_id": "0", "content": "阿斯达", "program_id": "2,3", "status": "2", "range": "1", "obj": "5", "add_time": "2018-03-14 16:51:28", "is_handsel": "2", "atten_del": "", "up_time": null, "obj_phone": "13521121232", "programs": [{ "program_id": "2", "reserve": "4895", "program_name": "阿萨打算", "price": "0.0200", "sale_num": null }, { "program_id": "3", "reserve": "10", "program_name": "测试多个程序方案赠送1", "price": "0.0000", "sale_num": null }] }] } }) </script> </html>
使用在线HTML/CSS/JavaScript代码运行工具测试上述代码,可得如下运行效果
希望本文所述对大家vue.js程序设计有所帮助。
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程