为了账号安全,请及时绑定邮箱和手机立即绑定

我的不报错,也不产生效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./JS/react.min.js"></script>
    <script src="./JS/react-dom.min.js"></script>
    <script src="https://cdn.bootcss.com/babel-standalone/6.22.1/babel.min.js"></script>
</head>
<body>
<div id="container"></div>
<script type="text/jsx">
    var TextClickComponent=React.createClass({
            handleClick:function (event) {

                var tipE=this.refs.tip;

                if(tipE.style.display==="none"){
                    tipE.style.display="inline";
                }
                else{
                    tipE.style.display="none";
                }

                event.stopPropagation();
                event.preventDefault();
            },
        render:function () {
            return(
                    <div>
                        <button onclick={this.handleClick}>显示|隐藏</button><span>测试点击</span>
                    </div>
            )
        }
    });

    var TextInputComponent=React.createClass({
        getInitialState:function () {
            return{
                inputContent:''
 }
        },
        changeHandler:function (event) {
            this.setState({
                inputContent:event.target.value
            });
            event.preventDefault();
            event.stopPropagation();
        },
        render:function () {
            return(
                    <div>
                        <input type="text" onchange={this.changeHandler}/><span>{this.state.inputContent}</span>
                    </div>
            );
        }
    });
    ReactDOM.render(
            <div>
        <TextClickComponent/>
                <br/><br/>
        <TextInputComponent/>
    </div>,
            document.getElementById('container'));
</script>
</body>
</html>


正在回答

1 回答

span标签少了个 ref ,   <span ref="tip">测试点击</span>

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
React入门
  • 参与学习       122138    人
  • 解答问题       121    个

颠覆式前端UI开发框架React入门视频教程,赶紧学起来

进入课程

我的不报错,也不产生效果

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信