数组方法 map

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>数组map</title>
	</head>
	<body>
		<ul class="main">
			
		</ul>
		<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
		<script type="text/javascript">
			const menu = [
			    { icon: '<UserOutlined />', name: '修改信息', key: 'modifyInfo' },
			    { icon: '<FormOutlined />', name: '修改密码', key: 'modifyPassword' },
			    { icon: '<SettingOutlined />', name: '告警设置', key: 'setting' },
			    { icon: '<AppstoreOutlined />', name: '系统管理', key: 'mis' },
			    { icon: '<LoginOutlined />', name: '退出登录', key: 'logout' },
			];
			let lis = '';
			// ES6 解构 item 形参 ****************
			menu.map(({ icon, name, key }) => (
			lis += `<li key=${key}>
						<span>${name}</span>
						${icon}
					</li>`
			));
			console.log(lis);
			$('.main').html(lis);
		</script>
	</body>
</html>

上一篇:4399知名游戏-赛尔号图鉴的爬取


下一篇:2021-03-02