【发布时间】:2023-03-06 17:36:01
【问题描述】:
我正在尝试使用 react-file-viewer 预览 .docx 文件
<FileViewer
fileType={'docx'}
filePath={this.state.file} //this.state.file has path of the url data
id="output-frame-id"
allowFullScreen={true}
/>
当用户单击 .docx 文件进行预览时,它会引发异常:
TypeError: 无法设置属性 'src' of null
并指向下面的代码
let srcData = URL.createObjectURL(this.response); // It contains a Response type of blob
error at this line ---> document.querySelector('#output-frame-id').src = srcData;
有什么建议吗?
【问题讨论】:
-
你可能想使用
ref
标签: javascript html jquery reactjs