我試圖完成的是遍歷一個對象,每個對象都有一個type
屬性。目標是遍歷每個對象並將它們顯示在由它們的type
指定的行中。如何迭代對象,然後在不同的行中顯示?
我試圖做的是有前端,後端和用戶界面上單獨列。
我使用奧裏利亞框架,這是我的觀點:
<template>
<div class="project-preview-container container">
<div class="row" repeat.for="projectType of projectTypes">
<div class="col-md-3 project-preview" repeat.for="project of projects">
<h3 class="${project.type}">${project.type}</h3>
<h1>${project.name}</h1>
</div>
</div>
</div>
這裏是我的模型:
export class Portfolio {
constructor() {
this.header = "Portfolio";
this.projectTypes = ["Frontend", "Backend", "UI"];
this.projects = [
{
name: "Project Name 1",
type: "Frontend",
img: [
"Image 1",
"Image 2",
"Image 3"
],
descriptionTitle: [
"Description Title 1",
"Description Title 2",
"Description Title 3"
],
description: [
"Description 1",
"Description 2",
"Description 3"
]
},
{
name: "Project Name 2",
type: "Frontend",
img: [
"Image 1",
"Image 2",
"Image 3"
],
descriptionTitle: [
"Description Title 1",
"Description Title 2",
"Description Title 3"
],
description: [
"Description 1",
"Description 2",
"Description 3"
]
},
{
name: "Project Name 3",
type: "Backend",
img: [
"Image 1",
"Image 2",
"Image 3"
],
descriptionTitle: [
"Description Title 1",
"Description Title 2",
"Description Title 3"
],
description: [
"Description 1",
"Description 2",
"Description 3"
]
},
{
name: "Project Name 4",
type: "UI",
img: [
"Image 1",
"Image 2",
"Image 3"
],
descriptionTitle: [
"Description Title 1",
"Description Title 2",
"Description Title 3"
],
description: [
"Description 1",
"Description 2",
"Description 3"
]
}
]
}
}
任何和所有的反饋意見都被接受,謝謝!
爲什麼圖片中有兩行? – brk
爲了表明我的意思,讓我們說你有名爲的文件夾:前端,後端,用戶界面。在每個文件夾裏應該有它們各自的類型,但是發生的是我將內容複製到每個文件夾中。 – ARLCode