反应物化库不允许我关闭模态。带有错误模态不是功能。该库使用react-materialize的JQuery,这有点用处。
import React, { Component } from 'react';
import NavBarStyle from './NavBar.css';
import $ from 'jquery';
import './projects.css';
import {Button,NavItem,Dropdown,Navbar,Collection,CollectionItem,Modal,
Input,Row} from 'react-materialize'
import SideNavBar from './SideNavBar';
class AddProjectForm extends Component{
addProject = (e) =>{
e.preventDefault();
$('#modal').modal('close');
}
render(){
return(
<div>
<Modal id="modal" header='Add project'
ref={(el) => this.modal = el}
actions={this.submitButton}
trigger={<a href="#" className="btn grey darken-1 white-text">Add project</a>}
>
<form action="#" onSubmit={this.addProject}>
<button ref={(el) => this.submitButton = el} type="submit" className="col btn s6-offset">Add</button>
</form>
</Modal>
</div>
}
答案 0 :(得分:0)
可能是一种解决方法:
尝试触发隐藏的“模态关闭”类按钮的点击事件(我是说将其隐藏)
"$('.modal-close').trigger('click')"
答案 1 :(得分:0)
最新答案,但可以帮助其他人。 您是否尝试将其添加到按钮
modal="close"