当前位置:网站首页>列表渲染 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>
边栏推荐
猜你喜欢
随机推荐
C语言——函数的使用
LeetCode1166. Designing File Systems
【记录】innerHeight?clientHeight?offsetHeight?scrollTop?screenTop?.....一堆高度傻傻分不清
Blender 初教程
QtDataVisualization 数据3D可视化
08-Express路由详解
【无标题】
leetcode21. Merge two ordered linked lists
[Verilog] I2S Master Test Bench
组件间通信
C语言——动态内存分配常见的错误案例
【win10+cuda7.5+cudnn6.0安装caffe②】安装Visual Studio 2013和caffe
【记录】TypeScript
06-JS定时器:间隔定时器、延时定时器
C语言结构体详解 (2) 结构体内存对齐,默认对齐数
pytorch中tensor 生成的函数
c指针学习(2)
【备忘】从零开始搭建Yolo5训练环境
C语言——文件操作(2)文件的读写操作
task05 PyTorch可视化









