请注意,当打开ngx-bootstrap-modal加载ngx-image-cropper时,会出现一些间歇性加载失败。我做了一些尝试和错误,我注意到,只要我在loadImageFailed()触发之前打开模式。裁剪机将会加载,并且一切似乎都运行正常。这与不渲染到DOM有关吗?
我找不到它的原因,或者我遗漏了什么?
希望能对此有所了解。
提前谢谢。
下面是该模式的外观:
<!-- EDIT MODAL -->
<article bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="dialog-sizes-name1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form (ngSubmit)="instructorService.updateCover(instructor.id)">
<section class="modal-header">
<h4 id="dialog-sizes-name1" class="modal-title pull-left">EDIT BANNER</h4>
<button type="button" class="close pull-right" (click)="lgModal.hide()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</section>
<section class="modal-body">
<cropper></cropper>
</section>
<section class="modal-footer d-flex bd-highlight">
<div class="mr-auto p-2 bd-highlight">
<input class="overflow-x" type="file" (change)="onSelectFile($event)" hidden #browser>
<button type="button" class="btn btn-pri" (click)="browser.click()"><b>BROWSE</b></button>
</div>
<div class="p-2 bd-highlight">
<button type="button" class="btn btn-sec btn-block"
(click)="lgModal.hide()"><b>CANCEL</b></button>
</div>
<div class="p-2 bd-highlight">
<button type="submit" class="btn btn-dark btn-block px-4"
(click)="lgModal.hide()"><b>SAVE</b></button>
</div>
</section>
</form>
</div>
</div>
</article>发布于 2021-01-20 16:31:26
设法通过将其与延迟加载组件方法挂钩来解决它。但我认为这可能只是一种变通办法。但是,嘿,在等待别人照亮的时候,这可能对你们中的任何一个人都有帮助。
了解如何延迟加载组件。我发现了Netanel Basal写的一篇很棒的文章。
https://netbasal.com/welcome-to-the-ivy-league-lazy-loading-components-in-angular-v9-e76f0ee2854a
干杯~
https://stackoverflow.com/questions/65787287
复制相似问题