当前位置:网站首页>列表渲染 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语言——逆序输出字符串的函数实现
- C - file operations fseek () function, ftell, rewind, rounding
- 【C语言从初阶到进阶】第一篇 初始C语言(一)
- task03 Pytorch模型定义
- 【备忘】于仕琪的libfacedetection相关
- 旅游住宿酒店14页
- Install different versions of MinGW (g++/gcc) and the configuration of the corresponding clion editor under Win
- C语言文件操作——数据文件类型、文件判断、文件缓冲区详解
- 【备忘】从零开始搭建Yolo5训练环境
- 普林斯顿概率论读本读书笔记(阅读中......)
猜你喜欢
随机推荐
自制病毒——整蛊
05-Nodejs中的模块加载机制
Flask framework learning: template rendering and Get, Post requests
【记录】TypeScript
CSDN 社区内容创作规范
Qt 字符串截取 查找字符串
Blender 初教程
Introduction of several ways to initialize two-dimensional arrays in C language (private way to initialize large arrays)
【CSDN21天学习挑战赛】第一天,配置环境外加实现mnist手写数字识别
第13章类继承
C语言动态内存分配(1)三种函数讲解
手推卷积神经网络参数(卷积核)求导
C语言版——通讯录进阶(文件版本)
task04 Pytorch进阶训练技巧
【转载】CMake 语法 - 详解 CMakeLists.txt
吃瓜教程task05 第6章 支持向量机
[C language from elementary to advanced] Part 1 Initial C language (1)
【C语言从初阶到进阶】第一篇 初始C语言(一)
看完这篇博客之后,含着泪学会了TCP/IP
c pointer learning (1)