Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Chrome和Firefox上获取语法错误_Javascript - Fatal编程技术网

Javascript 在Chrome和Firefox上获取语法错误

Javascript 在Chrome和Firefox上获取语法错误,javascript,Javascript,我正在尝试按照教程介绍如何显示WebViewer for pdf。但是我得到了这个错误 Uncaught SyntaxError: redeclaration of const docViewerindex.html:23:14note: Previously declared at line 20, column 12index.html:20:12 我可以看到有错误的重新声明,但我是新的,我不知道如何修复它。有人能告诉我吗,我对这个完全陌生 基于此, 我在这一页上看了一下。试图将常量更改为

我正在尝试按照教程介绍如何显示WebViewer for pdf。但是我得到了这个错误

Uncaught SyntaxError: redeclaration of const docViewerindex.html:23:14note: Previously declared at line 20, column 12index.html:20:12
我可以看到有错误的重新声明,但我是新的,我不知道如何修复它。有人能告诉我吗,我对这个完全陌生

基于此, 我在这一页上看了一下。试图将常量更改为let,但仍然没有帮助

 <!DOCTYPE html>
    <html>
    <head>
      <title>Basic WebViewer</title>
    </head>
    
    <!-- Import WebViewer as a script tag -->
    <script src='WebViewer/lib/webviewer.min.js'></script>
    
    <body>
      <div id='viewer' style='width: 1024px; height: 600px; margin: 0 auto;'></div>
      <script>
        WebViewer({
          path: 'WebViewer/lib', // path to the PDFTron 'lib' folder on your server
          licenseKey: 'Insert commercial license key here after purchase',
          initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
          // initialDoc: '/path/to/my/file.pdf', // You can also use documents on your server
        }, document.getElementById('viewer'))
        .then(instance => {
          const docViewer = instance.docViewer;
          const annotManager = instance.annotManager;
          docViewer.on('documentLoaded', () => {});
        });
      </script>
    </body>
    </html>

基本网络浏览器
网络浏览器({
路径:“WebViewer/lib”,//服务器上PDFTron“lib”文件夹的路径
licenseKey:“购买后在此插入商业许可证密钥”,
initialDoc:'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
//initialDoc:'/path/to/my/file.pdf',//您还可以使用服务器上的文档
},document.getElementById('viewer'))
。然后(实例=>{
const docViewer=instance.docViewer;
const annotManager=instance.annotManager;
on('documentLoaded',()=>{});
});
试试:

是什么解决了它

.then(instance => {const { docViewer, annotManager } = instance;
    docViewer.on('documentLoaded', () => {});
.then(instance => {const { docViewer, annotManager } = instance;
    docViewer.on('documentLoaded', () => {});