加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – 如何让我的React应用程序使用crud渲染Bootstrap表

发布时间:2020-12-15 20:18:57 所属栏目:百科 来源:网络整理
导读:我正在使用以下代码生成一个简单的UI,我正在尝试将其转换为使用Bootstrap. 这是我的原始代码(使用Skeleton); render:function(){ return ( div className="grocery-item row" div className="six columns" h4 className={this.props.item.purchased ? "strik
我正在使用以下代码生成一个简单的UI,我正在尝试将其转换为使用Bootstrap.

这是我的原始代码(使用Skeleton);

render:function(){
        return (
            <div className="grocery-item row">
                <div className="six columns">
                    <h4 className={this.props.item.purchased ? "strikethrough" : "" }>
                        {this.props.item.name}
                    </h4>
                </div>
                <form onSubmit={this.togglePurchased} className="three columns">
                    <button className={this.props.item.purchased ? "btn btn-danger" : "button-primary"}>{this.props.item.purchased ? "unbuy" : "buy"}</button>
                </form>
                <form className="three columns" onSubmit={this.delete}>
                    <button>&times;</button>
                </form>
            </div>
        )
    }

我尝试过做这样的事情;

render:function(){
        return (        
          <table class="table table-striped">
            <thead>
              <tr>
                <th>Column 1</th>
                <th>Columan 2</th>
                <th>Columan 3</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <h4 className={this.props.item.purchased ? "strikethrough" : "" }>{this.props.item.name}</h4>
                <form onSubmit={this.togglePurchased} className="three columns">
                  <button className={this.props.item.purchased ? "btn btn-danger" : "button-primary"}>{this.props.item.purchased ? "unbuy" : "buy"}</button>
                </form>
                <form className="three columns" onSubmit={this.delete}>
                    <button>&times;</button>
                </form>
              </tr>
            </tbody>
          </table>
        )
    }

但它并没有像我期望的那样发挥作用.我用react-express-examplar作为我的起点.

如何在我的React应用程序中使用Bootstrap表?

解决方法

如果您使用 create-react-app启动应用程序,我认为您将有更轻松的时间.他们甚至会给出 instructions on how to use Bootstrap with React.

你说你是React的新手.有许多活动部件一开始可能难以理解.使用create-react-app将会消除大量的学习曲线,并使您更容易开始尽可能少的摩擦.

祝好运!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读