【问题标题】:Is it possible to change the order of an ion-row?是否可以更改离子排的顺序?
【发布时间】:2021-08-06 03:58:42
【问题描述】:

我正在实现一个响应式网格,就像您在图片中看到的那样:

我知道在 Ionic 中可以更改列的顺序,但是是否可以对行执行相同的操作?

例如,目前,行的顺序是红、黄、绿。 我希望大屏幕显示为绿色、红色和黄色。这可能吗?类似于 offset-* or push-* and pull-* 但用于行。

或者您会尝试找到更好的方法吗?也许是另一种使用列的结构,我们知道可以对其进行排序。

现在,这是我的代码:

  <ion-grid>
    <ion-row>
      <ion-col col-12>
        <ion-row>
          <ion-col>
            Things inside
          </ion-col>
        </ion-row>

        <ion-row>
          <ion-col>
            Things inside
          </ion-col>
        </ion-row>

        <!-- I want this row to be the first on large screens -->
        <ion-row>
          <ion-col>
            Things inside
          </ion-col>
        </ion-row>
      </ion-col>

      <ion-col col-12>
        Things inside
      </ion-col>
    </ion-row>
  </ion-grid>

【问题讨论】:

标签: html ionic3 responsive ion-grid


【解决方案1】:
  • 将每行内的数据移动到一个 javascript 对象并更改 UI 以实现一个 forEach 来加载所有数据
class ColData: any;
class RowData: ColData[];
class GridData: RowData[];
  • 当你想要屏幕尺寸时
window.attachEvent('onresize', function(event) {
  // trigger here
});

改变对象的顺序

PS:你可能不得不使用 changedetector

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    • 1970-01-01
    • 2010-10-06
    • 2019-06-09
    • 2010-09-12
    相关资源
    最近更新 更多