当前位置:网站首页>列表渲染 map 与 v-for
列表渲染 map 与 v-for
2022-08-11 05:17:00 【-加油】
1、react App.js
const songs = [
{
id: 1,
name: 'hhhhh'
},
{
id: 2,
name: 'xxxxx'
},
{
id: 3,
name: 'aaaaa'
}
]
function App() {
return (
<div className="App">
<ul>
{
songs.map(song => <li key={
song.id}>{
song.name}</li>)}
</ul>
</div>
);
}
export default App;
2、vue App.vue
<template>
<div id="app">
<ul v-for="song in songs" :key="song.id">
<li>{
{
song.name}}</li>
</ul>
</div>
</template>
<script>
export default {
data() {
return {
songs: [
{
id: 1,
name: 'hhhhh'
},
{
id:2,
name:'xxxxx'
},
{
id:3,
name:'aaaaa'
}
]
}
}
}
</script>
<style>
</style>
边栏推荐
猜你喜欢
随机推荐
CSDN 社区内容创作规范
【win10+cuda7.5+cudnn6.0安装caffe⑥】报错及处理方式
做款好喝的茶饮~
第9章 内存模型和名称空间
性能效率测试
更新啦~人生重开模拟器自制
表单input控件数据双向绑定
第10章 对象和类-2
leetcode21. Merge two ordered linked lists
简单做份西红柿炒蛋778
设计三级联动
LeetCode1166. Designing File Systems
task02 fashion-mnist分类实战
【转载】CMake 语法 - 详解 CMakeLists.txt
[C language advanced] The first in-depth analysis of the storage of integer data in memory (1)
Install different versions of MinGW (g++/gcc) and the configuration of the corresponding clion editor under Win
05-JS中的BOM和DOM
LeetCode43. String multiplication (this method can be used to multiply large numbers)
Randomly generate uuid using rand function
PHP提高并发能力有哪些方案









