源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

React中jquery引用的实现方法

  • 时间:2022-01-29 04:35 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:React中jquery引用的实现方法
在React中引用Jquery比较好玩,获取元素的数据更多 1.引入方法举例:
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.界面样式 [img]http://files.jb51.net/file_images/article/201709/2017091214080821.png[/img] 3. 控制台打印结果 [img]http://files.jb51.net/file_images/article/201709/2017091214080822.png[/img]  4.text对象部分属性 [img]http://files.jb51.net/file_images/article/201709/2017091214080823.png[/img] 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部