2
對於使用Polymer的應用程序,我需要一個3x3網格。它不必響應,因爲它總是顯示在具有特定屏幕的設備上。目前這是我的網格看起來如何:具有固定行和列的聚合物網格
<div flex style="height: calc(100%/3);" horizontal layout flex>
<div flex style="height: 100%;">content</div>
<div flex style="height: 100%;">content</div>
<div flex style="height: 100%;">content</div>
</div>
<div flex style="height: calc(100%/3);" horizontal layout flex>
<div flex style="height: 100%;">content</div>
<div flex style="height: 100%;">content</div>
<div flex style="height: 100%;">content</div>
</div>
<div flex style="height: calc(100%/3);" horizontal layout flex>
<div flex style="height: 100%;">content</div>
<div flex style="height: 100%;">content</div>
<div flex style="height: 100%;">content</div>
</div>
現在,我需要用一個對象的內容來填充它。我知道如何輕鬆地將3個元素的數組插入其中一行,但我不知道如何用9個元素的數組填充所有9個內容區域。
<div flex style="height: calc(100%/3);" horizontal layout flex>
<template repeat="{{category in mainCategories }}">
<div flex style="height: 100%; background-color: {{category.color}};">{{category.text}}</div>
</template>
</div>
這是物體看起來像什麼(正好3個元素,否則會搞亂了):
Polymer('my-app', {
mainCategories: [
{
"text" : "Cat 1",
"color" : "red"
},{
"text" : "Cat 2 ",
"color" : "green"
},{
"text" : "Cat 3",
"color" : "yellow"
}
]
});
但我想這mainCategories
對象正好9個元素長,我想用這些值填充網格。這是可能的目前的設置,或者我不應該使用這樣的網格系統?
要小心,這是元素已被棄用0.5似乎。 [鏈接](https://www.polymer-project.org/0.5/docs/elements/core-layout-grid.html) – ShaBANG 2015-12-05 03:37:40
不幸的是,這個答案已經過時,因爲.42是當時最新的版本。如果你找到更好的解決方案,一定要發佈:) – ChargerIIC 2016-01-04 22:05:32