【问题标题】:ionic 6 : Modal Controller not scrollingionic 6:模态控制器不滚动
【发布时间】:2022-11-10 02:17:46
【问题描述】:

我有一个离子模态控制器,它在单击按钮时显示。对我来说,如果模态组件中的 ion-item 具有来自对象数组的详细信息,则模态不会滚动。 我看不到最初没有显示在屏幕上的列表的其余部分。

模态控制器

    console.log('Called');

    this.modalController
      .create({
        component: CagesComponent,
        breakpoints: [0.75],
        initialBreakpoint: 0.75,
        showBackdrop: true,
        backdropDismiss: true,
      })
      .then((modalEl) => {
        modalEl.present();
        return modalEl.onDidDismiss();
      })
      .then((resultData) => {
        console.log(resultData.data, resultData.role);
        if (resultData.role === 'confirm') {
          this.form.get('cageNo').setValue(resultData.data);
        }
      });
  }

笼子.component.html

<ion-list>
  <ion-item button (click)="onCageSelect(cage)" *ngFor="let cage of cages">
    <ion-thumbnail slot="start" >
      <img [src]="cage.cageImg">
    </ion-thumbnail>
    <div class="item-desc">
      <h4>{{cage.name}}({{cage.type}})</h4>
      <h6>{{cage.description}}</h6>
    </div>
  </ion-item>
</ion-list>
</div>

笼子组件.ts

import { IonicModule, ModalController } from '@ionic/angular';
import { Cage } from 'src/app/cage/cage.model';
import { CageService } from 'src/app/cage/cage.service';

@Component({
  selector: 'app-cages',
  templateUrl: './cages.component.html',
  styleUrls: ['./cages.component.scss'],
})
export class CagesComponent implements OnInit {
  cages: Cage[] = [];
  constructor(
    public cageSrvc: CageService,
    public modalCtrl: ModalController
  ) {}

  ngOnInit() {
    this.cageSrvc.getCages().subscribe((cages) => {
      this.cages = cages;
    });
  }

  onCageSelect(cage: Cage) {
    console.log(cage.name);
    this.modalCtrl.dismiss(cage.name, 'confirm');
  }
}

【问题讨论】:

    标签: angular ionic-framework ionic6


    【解决方案1】:

    将所有内容放在 ion-content 中。

    <ion-content>
      <!-- Your contents-->
    </ion-content>
    

    【讨论】:

      【解决方案2】:

      离子含量并没有解决我的问题,它甚至不再显示我的模态。 我所做的是使用以下 css 将我的所有内容包装在一个容器中:

      
      .helper-container {
          height: 85vh;
          overflow-y: scroll;
        }
      
      

      将高度调整为您选择的任何值。

      【讨论】:

        猜你喜欢
        • 2019-01-17
        • 1970-01-01
        • 2012-11-18
        • 2018-02-26
        • 2021-03-04
        • 1970-01-01
        • 2021-08-10
        • 1970-01-01
        • 2021-08-17
        相关资源
        最近更新 更多