小编DFX*_*yễn的帖子

[类型错误:无法读取未定义的属性“GlobalWorkerOptions”]

我的 pdfjs-dist 版本: "pdfjs-dist": "^2.4.456" 这是导入我的代码:

import PDFJS from 'pdfjs-dist'
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry'
Run Code Online (Sandbox Code Playgroud)

当我打电话时:

PDFJS.GlobalWorkerOptions.workerSrc = pdfjsWorker
this.loadingTask = PDFJS.getDocument({ data: self.pdfData })
Run Code Online (Sandbox Code Playgroud)

它返回此错误:[TypeError:无法读取未定义的属性“GlobalWorkerOptions”]

我尝试安慰这个:PDFJS,它返回undefinded

所以当我在互联网上尝试这个解决方案时,我添加

<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.5.207/pdf.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

在我index.htmladd var PDFJS = window['pdfjs-dist/build/pdf'];

然后它就可以完美工作...但我不知道为什么第一种方法对我不起作用...而且我不想从 CDN 使用它,因为我认为它对于我的项目来说不稳定。那么你们能给我指出我在这里错过的一点吗?我试图环顾四周node-modules以找出答案,但我仍然不明白为什么我不能import PDFJS from 'pdfjs-dist'

javascript npm vue.js pdfjs-dist

7
推荐指数
1
解决办法
9714
查看次数

如何在 Vuejs 中的某些特定文本(变量)中强制翻译 i18n

在正常情况下,我们只需将翻译属性附加到变量上,例如

this.name = this.$t('language.name');
Run Code Online (Sandbox Code Playgroud)

但我想有时用一种特定的语言来具体说明(例如:法语)。我们可以在 中做这样的事情vue.js吗?

this.name = this.$t('language.name', locale: fr);
Run Code Online (Sandbox Code Playgroud)

javascript python internationalization vue.js vue-i18n

6
推荐指数
1
解决办法
3133
查看次数

在 VScode 中调试 Python ( // 使用 IntelliSense 了解可能的属性。^ SyntaxError: invalid syntax )

我在 VScode 上使用了调试工具(ctrl + shift + D)和自定义的 launch.json,但我无法运行我的程序。帮我解决这个问题。 这是我的回溯

Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
 "__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
 exec(code, run_globals)
File "/home/odroid/.vscode-server/extensions/ms-python.python-2020.12.424452561/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
 cli.main()
File "/home/odroid/.vscode-server/extensions/ms-python.python-2020.12.424452561/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main
 run()
File "/home/odroid/.vscode-server/extensions/ms-python.python-2020.12.424452561/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file
 runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
File "/usr/lib/python3.6/runpy.py", line 261, in run_path
 code, fname = _get_code_from_file(run_name, path_name)
File "/usr/lib/python3.6/runpy.py", line 236, in _get_code_from_file
 code = compile(f.read(), fname, 'exec')
File "/home/odroid/Documents/python/crawling-worker/.vscode/launch.json", line 2
 // Use …
Run Code Online (Sandbox Code Playgroud)

python debugging remote-debugging web-crawler visual-studio-code

5
推荐指数
1
解决办法
5610
查看次数