繁体   English   中英

使用jQuery以编程方式在react-redux中关闭引导模式

[英]close bootstrap modal in react-redux programmatically using jquery

相信我们所有人都做得很好...我目前正在使用redux构建一个React应用程序,尝试以程序方式关闭bootstarp中的模式时遇到问题,我正在使用bootstrap 4jquery 3.3.1 ...我有尝试了这个:

 onSubmit(event) {
   event.preventDefault();
    this.props.editBusinessAction(this.props.id, this.state)
      .then((message) => {
        $('#modal').modal(hide)
      toastrOption();
      toastr.success(message);
   })
  .catch((message) => {
    toastrOption();
    toastr.error(message);
    console.log(message);
  });

}

尝试将hide放在这样的引号中:

 onSubmit(event) {
   event.preventDefault();
    this.props.editBusinessAction(this.props.id, this.state)
      .then((message) => {
        $('#modal').modal('hide')
      toastrOption();
      toastr.success(message);
   })
  .catch((message) => {
    toastrOption();
    toastr.error(message);
    console.log(message);
  });

}

$('#modal')。modal('hide')仅当您在条目组件中导入jquery和bootstrap时才有效。

在您的启动组件中安装jquery和bootstrap并将jquery导入,例如:App.js如下

npm install -s jquery@2.2.3 bootstrap@3.3.6

App.js

import 'jquery';
import 'bootstrap/dist/js/bootstrap';
import 'bootstrap/dist/css/bootstrap.css';
export default class extends Component {
    render(){
      return (
         <div>App component</App>
      )
    }
}

暂无
暂无

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

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