简体   繁体   English

如何在 React-Bootstrap 中放置内联无线电控件?

[英]How can I put inline radio controls in React-Bootstrap?

I'm writing a personal Electron project with React-Bootstrap and Typescript but I can't put two radio controls next to each other.我正在使用 React-Bootstrap 和 Typescript 编写一个个人 Electron 项目,但我不能将两个无线电控件放在一起。 I followed the React-Bootstrap examples but it won't work.我遵循了 React-Bootstrap 示例,但它不起作用。 I'm not sure if it's just me or if I'm missing something.我不确定这只是我还是我错过了什么。 I also tried giving the inline props to the Form component, and writing it without the Container and Row components as well.我还尝试将内联道具提供给 Form 组件,并在没有 Container 和 Row 组件的情况下编写它。 I know it can be done playing around with the flex structure in Bootstrap but I'd rather stick to the React-Bootstrap components only.我知道它可以在 Bootstrap 中使用 flex 结构来完成,但我宁愿只坚持使用 React-Bootstrap 组件。

import React from 'react';
import { Container, Row, Form  } from 'react-bootstrap';


const ExperimentTypeForm = () => {
  return (
    <Container fluid>
      <Row>
        <Form>
          <div key="inline-radio" className="mb-3">
            <Form.Check inline label="1" type="radio" id="inline-radio-1" />
            <Form.Check inline label="2" type="radio" id="inline-radio-2" />
          </div>
        </Form>
      </Row>
    </Container>
  )
}

export default ExperimentTypeForm;

I was missing the.css import from Bootstrap:我错过了从 Bootstrap 导入的 .css :

import 'bootstrap/dist/css/bootstrap.min.css';

At first I ignored it because I couldn't get it to compile due to some missing configuration in my webpack config file.起初我忽略了它,因为由于我的 webpack 配置文件中缺少一些配置,我无法编译它。 But after some digging I found this great answer on how to add the Bootstrap stylesheet to the App.tsx component.但经过一番挖掘后,我发现了关于如何将 Bootstrap 样式表添加到 App.tsx 组件的这个很好的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM