如何将使用ngfor打印的数据以角度分割为3列?

mid*_*ack 0 javascript split html-lists ngfor angular

数据

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30];
Run Code Online (Sandbox Code Playgroud)

我想将这些数据拆分为3列,并希望如下所示:

<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    ...
    <li>10</li>
</ul>
<ul>
    <li>11</li>
    <li>12</li>
    <li>13</li>
    ...
    <li>20</li>
</ul>
<ul>
    <li>21</li>
    <li>22</li>
    <li>23</li>
    ...
    <li>30</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

使用ngfor时如何拆分数据?

<ul *ngFor="let item of arr">
    <li>{{item}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

Arc*_*ezy 7

首先,它应该是这样的:

<ul>
    <li *ngFor="let item of arr">{{item}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

并在CSS中添加:

ul{
    -webkit-columns: 3;
    -moz-columns: 3;
    columns: 3;
}
Run Code Online (Sandbox Code Playgroud)