有什么方法可以预览vue.js中的docx文件吗?
Docx文件由带有input标记的type="file"上传。
我尝试过使用vue-doc-预览 npm,但是它需要在线url的url,而不是本地url。
发布于 2021-04-05 03:01:56
最后,我通过使用pdftron找到了解决方案。
@pdftron/webviewer。npm install --save @pdftron/webviewer"scripts": {
...
"postinstall": "node ./init-webviewer.js"
...
}init-webviewer.js。const fs = require('fs-extra');
const copyFiles = async () => {
try {
await fs.copy('./node_modules/@pdftron/webviewer/public', './public/webviewer/');
} catch (err) {
console.error(err);
}
};
copyFiles();...
<div ref='viewer'"></div>
...
import WebViewer from '@pdftron/webviewer';
...
WebViewer({
path: `${process.env.BASE_URL}webviewer`,
fullAPI: true
}, this.$refs.viewer)
.then((instance) => {
instance.loadDocument(this.file); // this.file is the File object to be uploaded.
});https://stackoverflow.com/questions/66939308
复制相似问题