【发布时间】:2017-10-03 14:58:56
【问题描述】:
我认为我一定是以某种方式导入了这个错误,但我不确定。我按照github 上的指示进行操作。它说我可以npm install 它然后只是import swal from 'sweetalert2'。我还必须使用js 和css 文件吗?
发生的情况是,我在窗口的左下方发出了一个不会消失的奇怪警报。
这是我的代码:
import React, { Component } from 'react';
import swal from 'sweetalert2';
class TestSwal extends Component {
componentDidMount() {
swal({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keep it'
}).then(
function() {
swal('Deleted!', 'Your imaginary file has been deleted.', 'success');
},
function(dismiss) {
// dismiss can be 'overlay', 'cancel', 'close', 'esc', 'timer'
if (dismiss === 'cancel') {
swal('Cancelled', 'Your imaginary file is safe :)', 'error');
}
}
);
}
render() {
return <div>Test Swal</div>;
}
}
export default TestSwal;
【问题讨论】:
标签: javascript node.js reactjs sweetalert sweetalert2