【问题标题】:Error while display pdf-viewer in bootstrap modal在引导模式中显示 pdf-viewer 时出错
【发布时间】:2019-01-02 06:02:12
【问题描述】:

我正在尝试预览 pdf,我正在使用引导模式,但出现以下错误:

无法初始化查看器类型错误:无法读取未定义的属性“div”

当我调用我的模态时,pdf 不会显示在模态中,但是如果我将滚动条从左向右移动,那么我可以在模态中看到 pdf。有没有人遇到同样的问题?解决这个问题的最佳解决方案是什么?

<div class="modal fade" id="preview{{f.id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLongTitle">{{ f.name }}</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div *ngIf="this['sourceIMG' + f.id]!=null">
                    <img class="img-fluid d-block mx-auto" [src]="this['sourceIMG' + f.id]" />
                </div>
                <pdf-viewer [src]="this['sourcePDF' + f.id]"
                            [render-text]="true" [page]="page"
                            [show-all]="true" style="display:block">
                </pdf-viewer>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

【问题讨论】:

    标签: angular pdf bootstrap-4


    【解决方案1】:

    github上有一个关于这个问题的持续问题。使用 NgIf 显示或隐藏 pdf-viewer 时会出现问题。

    请检查ThisThis

    【讨论】:

    • 我不知道谁投了反对票。实际上,当我用 *ngIf 隐藏它时它工作正常。它只会在引导模式中引发错误。
    • 在模态中,pdf-viewer 最初是隐藏的,对吗?因此出现问题。检查问题你会明白我的意思
    • 我已经看过了,但我说当我用 ngIf 隐藏时它可以正常工作。这就是我现在显示预览的方式。但我会很高兴把它放在一个模态中。
    • 您可以尝试使用模态但默认为已初始化。我的意思是把 ngIf=true 放在你的模式中以查看行为
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-28
    • 2021-12-27
    • 1970-01-01
    • 2018-07-13
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多