2
我發現這個完美的甜警報模塊引導並作出反應(我用我的流星應用程序,它):添加甜警報彈出到按鈕陣營組件
http://djorg83.github.io/react-bootstrap-sweetalert/
但我不明白如何將這些代碼包含在React組件中。
當有人在我的應用程序中單擊刪除按鈕時,我想要一個Sweet Alert提示來彈出詢問確認。
這裏是我的刪除按鈕組件:
import React, {Component} from 'react';
import Goals from '/imports/collections/goals/goals.js'
import SweetAlert from 'react-bootstrap-sweetalert';
export default class DeleteGoalButton extends Component {
deleteThisGoal(){
console.log('Goal deleted!');
// Meteor.call('goals.remove', this.props.goalId);
}
render(){
return(
<div className="inline">
<a onClick={this.deleteThisGoal()} href={`/students/${this.props.studentId}/}`}
className='btn btn-danger'><i className="fa fa-trash" aria-hidden="true"></i> Delete Goal</a>
</div>
)
}
}
這裏是我從甜警報例子複製的代碼:
<SweetAlert
warning
showCancel
confirmBtnText="Yes, delete it!"
confirmBtnBsStyle="danger"
cancelBtnBsStyle="default"
title="Are you sure?"
onConfirm={this.deleteFile}
onCancel={this.cancelDelete}
>
You will not be able to recover this imaginary file!
</SweetAlert>
任何人都知道如何做到這一點?
這工作完美!感謝您的快速和徹底的迴應,@hinok非常感謝! –
好教程的人! –
@hinok我怎麼能解析messsage由variabe那裏,我只是把變量,並得到一個錯誤 –