由于此项目的特性,我需要使用不在 node_modules 文件夹中的直接路径将jQuery
导入我的main.js
,但我无法执行此操作。我发现的所有问题都指向jquery
node_modules
我有这个
import {MyModule} from './components/myModule.js';
import jQuery from './jquery/jquery-3.3.1.js';
MyModule
按预期工作(在Chrome上),但jQuery产生:
Uncaught SyntaxError:请求的模块不提供名为“default”的导出
jquery-3.3.1.js是jQuery.com的uncompressed, development jQuery 3.3.1版本,我也尝试过生产版本。
我应该如何导入它?
编辑:
不是How to import jquery using ES6 syntax?的副本。因为import {$,jQuery} from 'jquery';
在node_modules
上搜索,当我从给定路径导入时,我会收到上面引用的错误。
答案 0 :(得分:1)
您尝试过吗:
import * as jQuery from './jquery/jquery-3.3.1.js'
https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Instructions/import