onz*_*sky 6 ionic-framework ionic5
我正在使用ion-popover。
在文档中的示例中,当您单击右上角的三个点时,弹出框显示在单击的按钮旁边。
重现这种情况的好方法是什么?有没有内置的方法?
由于我没有找到方法,我试图手动设置弹出框的样式,但这也不起作用。
我的页面.ts
const popover = await this.popoverController.create({
component: OptionsComponent,
cssClass: 'my-custom-class',
event: ev
});
return await popover.present();
Run Code Online (Sandbox Code Playgroud)
我的global.scss
.my-custom-class .popover-content {
position: absolute;
right: 0;
top: 0;
}
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?有没有更好的方法来解决这个问题?
Séb*_*ien 20
它在文档中解释(强调我的):
要呈现弹出框,请在弹出框实例上调用当前方法。为了相对于 clicked 元素定位 popover,需要将 click 事件传递到本方法的 options 中。
HTML
<div (click)="showPopover($event)">
<div>AAA</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在您的课程中,将事件作为参数传递给您的方法:
showPopover(event) {
const popover = await this.popoverController.create({
event,
component: OptionsComponent,
cssClass: 'my-custom-class', // optional
});
return await popover.present();
}
Run Code Online (Sandbox Code Playgroud)
不需要额外的 CSS,除非您想设置模态内容的样式。
| 归档时间: |
|
| 查看次数: |
3671 次 |
| 最近记录: |