首页 > 解决方案 > 如何在 ReactJS 中的 src={pdf} 之后添加#toolbar=0

问题描述

我想以模式显示 PDF,使用

import pdf from '../media/pdf/mypdf.pdf'

<iframe src={pdf} width="100%" height="600px"></iframe>

这很好用。

但我也想删除工具栏,所以我必须#toolbar=0在网址末尾添加

我该怎么做,由于某种原因,我不能将路径直接放入 src 属性,我必须使用一个变量,我不知道如何附加#toolbar=0它?

任何想法 ?

编辑:

从'../media/pdf/mypdf.pdf'导入mypdf

class HomeLayout extends Component {
    render() {
        return (
            <div className="App">
                <div className="container-fluid">
                <main>
                    <div className="modal fade" id="fichePremian" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                        <div className="modal-dialog modal-lg" role="document">
                            <div className="modal-content " >
                                <div className="modal-header">
                                    <button type="button" className="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div className="modal-body">
                                    <iframe src={mypdf} width="100%" height="600px"></iframe>
                                </div>
                            </div>
                        </div>
                    </div>
                </main >
            </div>
        </div>
        )//return
    }

}

export default HomeLayout;

标签: reactjs

解决方案


您是否尝试过这样做:<iframe src={pdf + '#toolbar=0'} width="100%" height="600px"></iframe>


推荐阅读