我是靠谱客的博主 懦弱冰淇淋,这篇文章主要介绍React中jquery引用的实现方法,现在分享给大家,希望可以做个参考。

在React中引用Jquery比较好玩,获取元素的数据更多

1.引入方法举例:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import $ from 'jquery'; import { Button } from 'antd'; class testJquery extends React.Component {   constructor(props) {     super(props);     this.selectElement = this.selectElement.bind(this);   }   render() {     return(       <div>         <Button onClick={this.selectElement}>点击一下</Button>         <h4 className="text">这是:12</h4>       </div>     );   }   selectElement() {     console.log('text对象:',$('.text'));     console.log('text中的值:',$('.text')[0].textContent);   } } export default testJquery;

2.界面样式

3. 控制台打印结果

 4.text对象部分属性

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

最后

以上就是懦弱冰淇淋最近收集整理的关于React中jquery引用的实现方法的全部内容,更多相关React中jquery引用内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(147)

评论列表共有 0 条评论

立即
投稿
返回
顶部