反应错误:无效的DOM属性`tabindex`。您是说`tabIndex`用Bbootstrap创建模态

问题描述 投票:0回答:1

对不起,我的英语:

我在React中创建了模态的组件,编译良好,但是控制台显示此错误:

警告:无效的DOM属性tabindex。你是说tabIndex吗?在div(在ModalComponent.js:10中)在div(在ModalComponent.js:5中)在ModalComponent(在src / index.js:24中)在div(在src / index.js:23)中在ModalCreate(在src / index.js:32)在StrictMode中(在src / index.js:31)

我知道,在作出反应时,属性必须为camalCase,但引导程序需要此属性才能起作用。有我的代码:

const ModalComponent = (props) => {
return (
    <div> {/* Tiene qe haber un solo elemento Padre */}
        <button type="button" className="btn btn-primary" data-toggle="modal" data-target={props.obj.id}>
            {props.obj.btnCallModal}
        </button>

        <div className="modal fade" id={props.obj.id} tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div className="modal-dialog" role="document">
                <div className="modal-content">
                    <div className="modal-header">
                        <h5 className="modal-title" id="exampleModalLabel">{props.obj.titulo}</h5>
                        <button type="button" className="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div className="modal-body">
                        {props.obj.body}
                    </div>
                    <div className="modal-footer">
                        <button type="button" className="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button type="button" className="btn btn-primary">{props.obj.btnInModal}</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
)

};

reactjs bootstrap-4 bootstrap-modal jsx
1个回答
0
投票

在反应中,tabIndex对应于html中的tabindex。将其更改为tabIndex,并且模式应该可以按预期工作。

© www.soinside.com 2019 - 2024. All rights reserved.