ES6 import – jQuery is not defined

2019-08-14 16:37发布

问题:

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

The following is my file structure.

app.js

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

jquery-plugin.js

(function($) {

    // Plugin code here

}(jQuery));

Any ideas?

回答1:

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'