【发布时间】:2021-05-19 06:05:14
【问题描述】:
我正在尝试将 editorjs (https://editorjs.io/) 集成到我的项目中,然后我将 editor.js 下载到我的项目中并将其加载到我的 html 页面中:
<script src='lib/editor.js'></script>
我补充说:
<script src='lib/myeditorloader.js'></script>
其中包含:
import EditorJS from '@editorjs/editorjs';
const editor = new EditorJS('editorjs');
我收到了那个错误:
Uncaught SyntaxError: Cannot use import statement outside a module
我添加了type='module' 来获取,因为 js 从来都不是简单的事情,所以我收到了这个错误:
Uncaught TypeError: Failed to resolve module specifier "@editorjs/editorjs".
Relative references must start with either "/", "./", or "../".
我试过import EditorJS from './editor.js';,但现在我明白了:
Uncaught SyntaxError: The requested module './editor.js' does not provide an export named 'default'
editojs 有问题还是什么?
【问题讨论】:
-
能否请您从问题中删除您对 JS 的看法
-
由于您想直接在 html 中包含 JS,您可以使用 CDN
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>而不是直接使用节点模块来处理 html 变得困难,这需要捆绑器、解析器、babel 等等跨度> -
我对NodeJS一无所知,在他们的“入门”中,他们提供了三种安装方式,composer,CDN和Manual,我选择了第三种,他们说要下载js和用这种方式,我的错在哪里?
-
@Andreas 我删除了我对 JS 的看法 ;-)
标签: javascript