Vue遍历数组、对象元素
·
📑前言
本文主要是【Vue】——Vue遍历数组、对象元素的文章,如果有什么需要改进的地方还请大佬指出⛺️
🎬作者简介:大家好,我是听风与他🥇
☁️博客首页:CSDN主页听风与他
🌄每日一句:狠狠沉淀,顶峰相见
Vue遍历数组、对象元素
示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="Application">
<div v-for="item in list">
{{item}}
</div>
<div v-for="item in k">
{{item.name}}
{{item.num}}
</div>
</div>
<script>
const App = {
data(){
return{
list:[1,2,3,4,5],
k:[
{
name:'辉少',
num:'151xxxxxxxxx'
},
{
name:'刘少',
num:'151xxxxxxxxx'
},
{
name:'张少',
num:'151xxxxxxxxx'
},
{
name:'李少',
num:'151xxxxxxxxx'
},
]
}
}
}
Vue.createApp(App).mount("#Application")
</script>
</body>
</html>
运行截图:
📑文章末尾
更多推荐
所有评论(0)