最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use ALERTIFY JS in React? - Stack Overflow

programmeradmin13浏览0评论

I'm trying to use ALERTIFYJS in react but its alertify alerts are not working. Below is the code

(window.alert is working fine on my browser)

import alertify from 'alertifyjs';

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

I'm trying to use ALERTIFYJS in react but its alertify alerts are not working. Below is the code

(window.alert is working fine on my browser)

import alertify from 'alertifyjs';

clickHandle = () => {
  alertify.alert('Alert Title', 'Alert Message!', function(){ 
    alertify.success('Ok'); 
  });
}
Share Improve this question edited Oct 12, 2020 at 6:29 Sultan Aslam asked Sep 2, 2018 at 14:49 Sultan AslamSultan Aslam 6,2382 gold badges40 silver badges48 bronze badges 7
  • what is not working? – Arup Rakshit Commented Sep 2, 2018 at 14:51
  • @ArupRakshit alertify alerts – Sultan Aslam Commented Sep 2, 2018 at 14:53
  • Any errors in the console that might give you a hint on why it's not working? – Deepak Kamat Commented Sep 2, 2018 at 14:55
  • no errors even in console its showing everything ok. if i console alertify its show there is a function alert – Sultan Aslam Commented Sep 2, 2018 at 14:56
  • 1 You should add the css file tooo – Ramesh Kithsiri HettiArachchi Commented Oct 30, 2018 at 9:57
 |  Show 2 more comments

2 Answers 2

Reset to default 14

Need to add the css file too. Problem Solved.

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

Yes, You have to add css file as well.

Here is the process for adding css and importing 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

发布评论

评论列表(0)

  1. 暂无评论