【问题标题】:Ion-select not working离子选择不起作用
【发布时间】:2018-09-24 08:27:36
【问题描述】:

我正在使用 Ionic 3,我想实现 ion-select,我遵循了 ionic 文档,但我无法理解我的错误。我的代码在这里。

hosts: any[] = [
   '*MANAGER*',
   'Alberto Bellesini',
   'Alessandro Rodeghero',
   'Andrea Burla',
   ..............
];

在我的 html 中有

<ion-select [(ngModel)]="selectedHost">
    <ion-label>From:</ion-label>
    <ion-option *ngFor="let host of hosts" [value]="host"></ion-option>
</ion-select>

它不起作用。我可以看到与我的数组长度相等的无线电数量,但所有元素似乎都是空的或未定义的:我什么都看不到。我已经尝试将hosts 作为字符串数组,但结果是一样的。有人可以帮我吗?

【问题讨论】:

  • 也许数组的长度有限制?因为我有 30 个元素
  • hosts: any[] = ['*MANAGER*', 'Alberto Bellesini'] 是糟糕的代码。请不要这样写

标签: typescript ionic3 angular5


【解决方案1】:

如果我理解正确,您只是看不到单选按钮的标签吗?

<ion-option *ngFor="let host of hosts" [value]="host">{{host}}</ion-option>

【讨论】:

  • 这不应该是评论吗?
  • 没错,我忘了加 {{ host }},而且我的 .css 中也有覆盖,所以我什么也看不到。
猜你喜欢
  • 2018-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-28
  • 2021-05-15
  • 2019-12-16
  • 2019-09-26
  • 1970-01-01
相关资源
最近更新 更多