// 定义车辆数据const cars = [
{ id: 1, brand: '奔驰', model: 'S-Class', price: '100 万' },
{ id: 2, brand: '宝马', model: 'X5', price: '80 万' },
{ id: 3, brand: '奥迪', model: 'A6', price: '50 万' }];// 渲染车辆信息的函数function renderCarList() {
const carList = document.getElementById('carList');
cars.forEach(car => {
const li = document.createElement('li');
li.innerHTML = `<h3>${car.brand} ${car.model}</h3><p>价格:${car.price}</p>`;
carList.appendChild(li);
});}// 调用渲染函数renderCarList();
暂时没有评论,来抢沙发吧~