var InlineButton = React.createClass({ onClick : function () { var $form = $("form.new_user_form"); var $buttons = $(".toggle-inputs button"); var mode = $(this.refs.inline).data("input"); $buttons.removeClass("active"); $(this.refs.inline).addClass("active"); if (mode === "inline") { $form.addClass("inline-input"); } else { $form.removeClass("inline-input"); } },getDefaultProps : function () { return { className : 'glow left active',dataInput:"inline" }; },render: function() { return ( <button onClick={this.onClick} ref="inline" className={this.props.className} data-input={this.props.dataInput}>{this.props.value} </button> ); } });
通过 ref 可获取当前的 render Object Element
原文链接:https://www.f2er.com/react/307517.html