【问题标题】:Remove divider of last item / chid in <ion-list>删除 <ion-list> 中最后一项 / chid 的分隔符
【发布时间】:2018-03-10 01:42:59
【问题描述】:

使用&lt;ion-list&gt; 时,如何设置最后一项不显示分隔符?

我有一个列表,其中有 2 个 *ng-For 通过 2 个数组。第一个数组将其他数组作为元素。

第一个数组元素之间的分隔符工作正常。但是,当显示第二个数组时,最后一项也有一个分隔符。

设置no-lines 属性会删除项目之间的所有分隔符,但我只想删除最后一个的分隔符。

当前最后一项的显示方式:

这是想要的结果:

我已经尝试过应用这个样式规则:

.md ion-list > .item:last-child, 
.md ion-list > .item-wrapper:last-child .item,
.wp ion-list > .item:last-child, 
.wp ion-list > .item-wrapper:last-child .item,
.ios ion-list > .item:last-child, 
.ios ion-list > .item-wrapper:last-child .item {
    border-bottom: none;
}

编辑

这是我当前的代码:

list.html

 <ion-list>
    <ion-item *ngFor="let obj of TestObject.charListArray">
      {{obj.variable}}

      <ion-item *ngFor="let person of obj.contactArray">
        {{person.lastname}}, {{person.firstname}} <br> 
        {{person.email}} <br>
        {{person.company}}
      </ion-item>

    </ion-item>
   </ion-list>

测试对象的类:

import { charSection } from '../home/charSection';
import { compactContact } from '../home/compactContact';

export class charList {
  charListArray: Array<charSection>;
  alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  chars = this.alphabet.split("");

  //Generates 26 charSection-Objects in this array
  constructor() {
    this.charListArray = [];
    for (let i in this.chars) {
      this.charListArray.push(new charSection(this.chars[i]));
    }
  }

CharSection 类:

import { compactContact } from '../home/compactContact';

export class charSection {
  contactArray: Array<compactContact>;

  constructor(public char: string) {
    this.contactArray = [];
  }

【问题讨论】:

  • 添加了更多我的代码。如果缺少其他任何内容或提供的信息不好/混乱/过于无序,我可以删除问题。

标签: angular ionic-framework


【解决方案1】:

你已经很接近了。这对我有用:

ion-item:last-child {
    --border-width: 0;
    --border-color: transparent;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 2012-12-21
    • 1970-01-01
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多