gpt4 book ai didi

node.js - 从 npm 包导入 jquery?

转载 作者:行者123 更新时间:2023-12-02 04:07:07 25 4
gpt4 key购买 nike

我已经通过 npm 安装了 jquery。

package.json:

    "jquery": "^3.2.1",

在我的 JS 中我这样做:

import $ from 'jquery';

但是它仍然说 $ 在我的浏览器中未定义,这是为什么?

最佳答案

问题是它没有 default 导出语法,但您使用了 default 导入。

尝试以下语法:

import * as $ from 'jquery'

关于node.js - 从 npm 包导入 jquery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46987866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com