First of all I'm still a newbie in web development. Okay, now to the question. I have these imports:
import $ from 'jquery';
window.jQuery = $;
window.$ = $;
global.jQuery = $;
import './assets/js/waves';
How do I properly import an external javascript to reactjs if my external javascript requires jquery?
Because based on what these guys have said:
my imports will be hoisted, which results in my external " ./assets/js/waves " js causing an error.
Uncaught ReferenceError: $ is not defined?
Thanks in advance!
import * as jQuery from 'jquery';
然后,您可以获得jQuery
的引用,并且可以根据需要使用它,例如:
window.$ = 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.