简体   繁体   English

ionic 4 离子选择选项文本换行

[英]ionic 4 ion-select-option text wrap

I'm unable to wrap the text in my ion-select-option.我无法将文本包裹在我的 ion-select-option 中。

 <ion-list> <ion-list-header>Select one of your work orders</ion-list-header> <ion-item> <ion-select [(ngModel)]="selection" (ionChange)="optionsFn(selection)"> <ion-select-option [value]="work" *ngFor="let order of workOrder">{{order.destination}} - {{order.startDate | date: "MM/dd/yyyy"}} - {{order.endDate | date: "MM/dd/yyyy"}}</ion-select-option> </ion-select> </ion-item> </ion-list>

I actually saw a solution using the following CSS我实际上看到了使用以下 CSS 的解决方案

 .alert-radio-label.sc-ion-alert-ios { padding-left: unset; padding-right: unset; -webkit-padding-start: 13px; padding-inline-start: 13px; -webkit-padding-end: 13px; padding-inline-end: 13px; white-space: pre-wrap; }

If I add white-space: pre-wrap;如果我添加空格: pre-wrap; in the console debugger the text from the ion-select will wrap successfully with the following:在控制台调试器中,来自 ion-select 的文本将使用以下内容成功包装:

在此处输入图片说明

The problem is if I add that to the css it doesn't take effect.问题是,如果我将其添加到 css 中,则它不会生效。 So I'm not sure where it should be added.所以我不确定应该在哪里添加。 In another post someone suggested adding it to the app.css but I don't have a global app.css in my ionic 4 project.在另一篇文章中,有人建议将其添加到 app.css 中,但我的 ionic 4 项目中没有全局 app.css。

由于警报 html 在您的组件之外,您需要将其添加到您的应用程序的全局 CSS 中...在 Ionic 4 生成的项目中,您可以使用 global.scss,如果找不到或它不起作用......使用variables.scss,虽然我认为你可以只使用global.scss。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM