在我的反应应用程序中使用selected.js

时间:2018-06-18 00:57:52

标签: javascript jquery node.js reactjs jquery-chosen

我正在尝试在我的反应应用程序中使用selected.js。 然而,虽然我已经阅读了关于refs和stuffs的文档(https://reactjs.org/docs/integrating-with-other-libraries.html),但我并没有真正得到它的任何内容。什么是ref,它究竟做了什么?我有我的反应代码,它不起作用。如果有人能解释这个参考和这个。$ el做了反应,我会很感激。

app.Run();

还有,

import React, { Component } from 'react';
import $ from 'jquery';
import { findDOMNode } from 'react-dom';

class Chosen extends Component {

    componentDidMount(){
        this.el = $(this.el);
        this.$el.chosen();
    }

    componentWillUnmount(){
        this.$el.chosen('destroy');
    }
    render() {
        return (
            <div>
                <select className="Chosen-select" ref={ el => this.el = el }>
                    { this.props.children }
                </select>
            </div>
        )
    }
}

export default Chosen;

0 个答案:

没有答案