大家好,欢迎来到IT知识分享网。
<template>
<div>
<h3>ListRender</h3>
<h3>遍历数组,不带key</h3>
<ul class="left">
<li v-for="(listone, index) in listones">
{
{
index }}:姓名: {
{
listone.name }},年龄: {
{
listone.age }},性别:
{
{
listone.sex }},手机号:{
{
listone.phone}}
</li>
</ul>
<h3>遍历数组,带key,这里的key关联age[这里是没有唯一性的,因为年龄可以相同]</h3>
<ul class="left">
<li v-for="(listone, index) in listones" :key="listone.age">
{
{
index }}:姓名: {
{
listone.name }},年龄: {
{
listone.age }},性别:
{
{
listone.sex }},手机号:{
{
listone.phone}}
</li>
</ul>
<h3>遍历数组,带key,这里的key关联phone[唯一性]</h3>
<ul class="left">
<li v-for="(listone, index) in listones" :key="listone.phone">
{
{
index }}:姓名: {
{
listone.name }},年龄: {
{
listone.age }},性别:
{
{
listone.sex }},手机号:{
{
listone.phone}}
</li>
</ul>
</div>
</template>
<script scoped>
export default {
name: "ListRender",
data() {
return {
listones: [
{
name: "姬天道", age: 40, sex: "男",phone:"18898836586" },
{
name: "姬老魔", age: 60, sex: "男" ,phone:"18898836587" },
{
name: "陆州州", age: 28, sex: "男" ,phone:"18898836588" },
{
name: "陆阁主", age: 28, sex: "男" ,phone:"18898836589" }
],
};
},
};
</script>
<style scoped>
.left{
text-align: left;
}
</style>
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/23426.html