Following the answer to this question I tried to import jQuery using import {$, jQuery} from 'jquery';
. and am getting the error Uncaught TypeError: (0 , _jquery.$) is not a function
in the browser. Am using Babel with the ES2015 preset to transpile my Code. If I use two separate imports ie import $ from 'jquery'; import jQuery from 'jquery'
import $ from 'jquery'; import jQuery from 'jquery'
then it works fine. Why can't I use the combined syntax?
Because import $ from 'jQuery'
is short for import {default as $} from 'jQuery'
. If you import {$, jQuery}
, those are two names that are not exported. You can however use
import {
default as $,
default as jQuery
} from 'jQuery';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.