React JavaScript是否支持jQuery? [英] Does React JavaScript support jQuery?
问题描述
我试图在React Js中使用jQuery,但是它显示了"$" is undefined
.是否需要安装一些软件包,或者React不支持jQuery.
对于您的特定问题,请尝试通过npm安装jQuery.
npm i jquery --save
或
yarn add jquery
然后,在您的模块中...
import $ from 'jquery'
有关如何解决此问题的文章此处
I'm trying to use jQuery in React Js but it shows that "$" is undefined
. Is there some package I need to install or does React does not support jQuery.
For your specific problem, try installing jQuery via npm.
npm i jquery --save
or
yarn add jquery
Then, in your modules...
import $ from 'jquery'
With that said, it's no easy thing to use jQuery and React together. React is unaware of changes made outside of the virtual DOM, and jQuery manipulates the standard DOM directly.
There's a write-up on how to approach this problem here.
这篇关于React JavaScript是否支持jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!