我是 Ionic 和移动开发的新手。我正在使用 ionic 列表,如何使文本全屏可用(请参阅图片中的最后收到)并且可以使用 <ion-label>
吗?周围<h4>
和 <p>
?
<ion-list>
<ion-item *ngFor ="let connection of connections">
<ion-avatar slot="start">
<img [src]="connection?.picture">
</ion-avatar>
<ion-label text-wrap>
<h4>{{ connection?.name}}</h4>
<p text-wrap> Last received: {{ connection?.locationDesc }}</p>
</ion-label>
<ion-label slot="end" text-right>
<p item-end> 2 Messages </p>
<ion-button clear slot="end">View</ion-button>
</ion-label>
</ion-item>
最佳答案
看起来它只需要一点点,但它实际上做的是与您放入的两个标签共享 50 50 以用作列。由于自动换行,它看起来只用了不到一半。
这是因为标签根据这些规则被设置为 flex 元素。
我设法做到了这一点:
通过使用此代码:
<ion-list>
<ion-item>
<ion-avatar slot="start">
<img src="/assets/matthew.jpg">
</ion-avatar>
<ion-label class="ion-text-wrap">
<h4>Some name</h4>
<p> Last received: All plugins have two components - the native code (Cordova) and the
JavaScript code. Cordova plugins are also wrapped in a Promise or Observable in order to provide a common
plugin interface. Below are various framework options using the Camera plugin as an example. </p>
</ion-label>
<ion-note class="ion-text-end">
<p> 2 Messages </p>
<ion-button clear>View</ion-button>
</ion-note>
</ion-item>
</ion-list>
基本上我将最后一个 ion-label
换成了 ion-note
。
我还搞砸了其他事情,比如删除不需要的插槽并将属性转换为 appropriate utility classes这现在被认为是最佳实践(因为他们引入了不支持这些属性的 React 和 Vue)。
关于html - 文本(标签)没有占用 ionic 列表中的所有可用空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58775790/