当前位置: 首页 > wzjs >正文

深圳集团网站建设公司好个体户查询系统官网

深圳集团网站建设公司好,个体户查询系统官网,商城网站功能文档,开发小程序定制软件目录 一、基本数据类型 二、循环对象 三、循环数组及嵌套结构 四、其他类型循环 五、总结 一、基本数据类型 在vue中,有对象、数组、字符串、数字等类型的结构,在模板渲染时,可以使用v-for省略大部分重复性的代码,特别是对对…

目录

一、基本数据类型

二、循环对象

三、循环数组及嵌套结构

四、其他类型循环

五、总结


一、基本数据类型

        在vue中,有对象、数组、字符串、数字等类型的结构,在模板渲染时,可以使用v-for省略大部分重复性的代码,特别是对对象和数组及对象和数组相互嵌套的结构的循环。我们需要了解遍历相关对象的key或value的写法。

二、循环对象

        对象就是由几组key:value形式所组成的一个结构对象,对应python中的字典。在vue中循环对象的话,可以选择只循环key或只循环value,当然也可以一组一组循环。

<template><!-- 只循环值的话使用解包形式,用index作为key。因为value可能会有重复,尽量不重复。 --><template v-for="(value, index) in Object.values(obj)" :key="index"><p style="text-align: center;">{{ value }}</p></template><template v-for="key in Object.keys(obj)" :key="key"><p style="text-align: center;">{{ key }}</p></template><template v-for="(value, key, index) in obj" :key="key"><p style="text-align: center;">{{ index }}.{{ key }}-{{ value }}</p></template>
</template><script setup>
import { ref, reactive } from 'vue'const obj = reactive({'title': 'title1','content': 'content1'
})</script>

 

三、循环数组及嵌套结构

        数组由多个项组成的,同python中的列表概念一样。循环列表,一样可以使用上述方法。

<template><!-- 不带index的循环列表中每一项 --><template v-for="item in listObj" :key="item.title"><p style="text-align: center;">{{ item.title }}-{{ item.content }}</p></template><!-- 带index循环列表 --><template v-for="(item, index) in listObj" :key="index"><p style="text-align: center;">{{ index }}.{{ item.title }}-{{ item.content }}</p></template><!-- 嵌套结构,逐级解包循环 --><template v-for="(item, index) in listObj" :key="index"><template v-for="(value, key, _) in item" :key="key"><p style="text-align: center;">{{ index }}.{{ item.title }}-{{ item.content }}</p></template></template>
</template><script setup>
import { ref, reactive } from 'vue'const listObj = reactive([{'title': 'title2','content': 'content2'},{'title': 'title3','content': 'content3'}
])</script>

 

四、其他类型循环

        其余类型的循环就比较好理解了,字符串则是循环每一个字符,数字循环则是从小到大。

<template><!-- 循环数字(可以带index) --><template v-for="i in 3" :key="i"><p style="text-align: center;">{{ i }}</p></template><!-- 循环字符串(可以带index) --><template v-for="i in 'String'" :key="i"><p style="text-align: center;">{{ i }}</p></template>
</template>

五、总结

        通过上面几种数据类型的遍历,发现循环的值可以有两个及以上的值,最后一个为当前遍历值在遍历对象下的index。且当遍历对象时,vue遵循值优先的理念,占位顺序分别为value, key,这点和其他语音有出入。

        对象:v-for="(value, key, index) in obj"

        数组:v-for="(item, index) in arr"


文章转载自:

http://bYiUDC9i.jtmqL.cn
http://w2SLOeRO.jtmqL.cn
http://vwzwxGOs.jtmqL.cn
http://Ca2nKRR7.jtmqL.cn
http://GIesi8Gq.jtmqL.cn
http://3g8knE6e.jtmqL.cn
http://YFc7g9pD.jtmqL.cn
http://L7jv98pC.jtmqL.cn
http://K53APMo3.jtmqL.cn
http://BPRANooa.jtmqL.cn
http://eIawG0K9.jtmqL.cn
http://OtpEUsng.jtmqL.cn
http://Ki6659XK.jtmqL.cn
http://d5RBTpWv.jtmqL.cn
http://gB4JSA4O.jtmqL.cn
http://uZVf1Hjf.jtmqL.cn
http://ugCspj2c.jtmqL.cn
http://Hy30ACSZ.jtmqL.cn
http://kSSfDEBL.jtmqL.cn
http://bC4p0Err.jtmqL.cn
http://REOWBOWD.jtmqL.cn
http://hEqf7Fuf.jtmqL.cn
http://8WiXge0M.jtmqL.cn
http://phtiEYKL.jtmqL.cn
http://JhIL4kLC.jtmqL.cn
http://bhuQAArk.jtmqL.cn
http://ny9Ma8zF.jtmqL.cn
http://6v9ZK7DI.jtmqL.cn
http://OEdYmjkc.jtmqL.cn
http://YW07b0jp.jtmqL.cn
http://www.dtcms.com/wzjs/652861.html

相关文章:

  • wordpress网站工具栏建设 大型电子商务网站
  • 河北省住房和城乡建设部网站站长工具查询seo
  • 甜品网站网页设计代码产品故事软文案例
  • 微商如何做网站引流峰峰专业做网站
  • 网站怎么制作视频设计之家软件
  • 公司网站规划wordpress对seo
  • dw个人网站设计模板免费杭州装饰装潢公司10大品牌
  • 企业站网站树莓派3 部署wordpress
  • 400网站建设电话wordpress 古典
  • 询价网站哪个好赣州微信公众号制作
  • 百度优化只做移动网站没有pc站新浪sae安装wordpress
  • 新闻发稿发布平台seo公司后付费
  • kkday是哪里做的网站开发网站开始的工作
  • wdlinux 默认网站免费建立网站步骤
  • 网站分页符怎么做宣传片制作公司有哪些公司
  • 做网站推广汉狮网络烟台网站排名优化公司哪家好
  • 上海响应式网站设计网站建设步骤详解视频教程
  • 网站包装推广之网络营销案例云浮头条新闻
  • 做公司网站客户群体怎么找短视频seo是什么
  • 邯郸中材建设有限责任公司网站请给自己的网站首页布局
  • 网页版梦幻西游礼包码昆明网络推广优化
  • 建设银行软件官方网站下载网络设备维护是做什么的
  • 江苏省建设集团有限公司网站百度知道个人中心
  • 文明网i中国精神文明建设门户网站外贸网站一站式海外推广
  • 网站地图提交给百度网盟推广图片
  • 中恒诚信建设有限公司网站哈尔滨公司网站开发
  • 上海网站建设包括哪些网站怎么识别手机跳转
  • led网站免费模板济源市住房和城乡建设局网站公示
  • 网站开发工程师认证必应搜索推广
  • dede 汽车网站模板外贸公司取名字大全