【问题标题】:React Datepicker CSS messed UpReact Datepicker CSS 搞砸了
【发布时间】:2020-08-13 23:21:04
【问题描述】:

我正在使用 HackerOne 的这个模块:https://reactdatepicker.com

在安装模块并将其导入我的项目后,我决定从站点中选择 Select time 组件。

我的代码

import React, { Component } from "react";
import { Form, Button } from "react-bootstrap"
import DatePicker from "react-datepicker"

export default class AddEventModal extends Component {

    constructor(props) {
        super(props)

        this.state = {
            date: new Date()
        }
    }

    render() {
        return (
            <Form>
                <Form.Group controlId="formBasicEmail">
                    <Form.Label>Title <span style={{ color: "red" }}>*</span></Form.Label>
                    <Form.Control type="text" placeholder="Enter a Title" className="col-6" />
                    <Form.Text className="text-muted">
                        Enter a Title for your Event.
                        </Form.Text>
                </Form.Group>

                <Form.Group controlId="formBasicPassword">
                    <Form.Label>Description</Form.Label>
                    <Form.Control type="text" placeholder="Enter a Description" className="col-6" />
                </Form.Group>

                <DatePicker
                    selected={this.state.date}
                    onChange={newDate => this.setState({ date: newDate })}
                    showTimeSelect
                    timeFormat="HH:mm"
                    timeIntervals={15}
                    timeCaption="time"
                    dateFormat="MMMM d, yyyy h:mm aa"
                />

                <Form.Group controlId="formBasicCheckbox">
                    <Form.Check type="checkbox" label="Check me out" />
                </Form.Group>
                <Button variant="success" type="submit">
                    Submit
                    </Button>
            </Form>

        );
    }
}

我的输出 https://i.stack.imgur.com/2L1Rv.png

不应该是这样的......该网站有工作演示。我做错了什么?

编辑:答案在 cmets 中。我错过了一个 CSS 导入

【问题讨论】:

    标签: css reactjs datepicker react-bootstrap react-datepicker


    【解决方案1】:

    好像我错过了一个 CSS 导入。太糟糕了,该网站没有明确提及这一点。

    import "react-datepicker/dist/react-datepicker.css"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-30
      • 2014-03-06
      • 2017-10-03
      • 2016-12-21
      • 1970-01-01
      相关资源
      最近更新 更多