简体   繁体   English

如何在 React 中使用 ALERTIFY JS?

[英]How to use ALERTIFY JS in React?

I'm trying to use ALERTIFYJS in react but its alertify alerts are not working.我正在尝试在 React 中使用 ALERTIFYJS,但它的 alertify 警报不起作用。 Below is the code下面是代码

(window.alert is working fine on my browser) (window.alert 在我的浏览器上运行良好)

import alertify from 'alertifyjs';

clickHandle = () => {
  alertify.alert('Alert Title', 'Alert Message!', function(){ 
    alertify.success('Ok'); 
  });
}

Need to add the css file too.还需要添加css文件。 Problem Solved.问题解决了。

import 'alertifyjs/build/css/alertify.css';

Yes, You have to add css file as well.是的,您还必须添加 css 文件。

Here is the process for adding css and importing alertify下面是添加css和导入alertify的过程

import alertify from 'alertifyjs';
import 'alertifyjs/build/css/alertify.css';

or或者

import * as alertify from 'alertifyjs';
import 'alertifyjs/build/css/alertify.css';

Please note I have tested this code on react js 16.13.1 with restify 1.13.1请注意,我已经在 react js 16.13.1 和 restify 1.13.1 上测试了这段代码

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

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