简体   繁体   English

ES6 导入 – jQuery 未定义

[英]ES6 import – jQuery is not defined

I'm using Gulp and Browserify for my build process, except I'm having trouble using third party jQuery plugins – showing error jQuery is not defined我在构建过程中使用 Gulp 和 Browserify,但我在使用第三方 jQuery 插件时遇到问题 – 显示错误jQuery is not defined

The following is my file structure.以下是我的文件结构。

app.js应用程序.js

import $ from 'jquery'
import plugin from 'jquery-plugin'

jquery-plugin.js jquery-plugin.js

(function($) {

    // Plugin code here

}(jQuery));

Any ideas?有任何想法吗?

Maybe you need use './'也许你需要使用'./'

import $ from 'jquery' import plugin from './jquery-plugin'

EDITED, my new answer below:编辑,我的新答案如下:

Try this way:试试这个方法:

import * as jqueryPlugin from 'jquery-plugin'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM