在react中引用jquery比较好玩,获取元素的数据更多
引入方法举例:
import $ from 'jquery'; import { button } from 'antd'; class testjquery extends react.component { constructor(props) { super(props); this.selectelement = this.selectelement.bind(this); } render() { return( <p> <button onclick={this.selectelement}>点击一下</button> <h4 classname="text">这是:12</h4> </p> ); } selectelement() { console.log('text对象:',$('.text')); console.log('text中的值:',$('.text')[0].textcontent); } } export default testjquery;
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
jquery判断是否浏览到网页底部
jquery使用iscorll实现手机端中上拉加载下拉刷新
以上就是jquery引用react步奏详解的详细内容。
