本文整理汇总了TypeScript中sweetalert2.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: alert
alert(options: any = {}, successCb = noop, closeCb = noop) {
const defaultOptions: any = {
type: options.type || null,
title: options.title || null,
text: options.text || null,
buttonsStyling: options.buttonsStyling || false,
confirmButtonClass : options.confirmButtonClass || 'btn btn-lg btn-secondary',
animation: options.animation || true,
customClass: options.customClass || '',
}
if (closeCb !== noop) {
defaultOptions.showCancelButton = options.showCancelButton || true
defaultOptions.cancelButtonClass = options.cancelButtonClass || 'btn btn-lg btn-secondary'
}
return swal(assign(defaultOptions, options))
.then(res => successCb(res), dismiss => closeCb(dismiss))
}
示例2: Error
export const getUser = (): UserData => {
const user = sessionStorage.getItem('auth_token');
if (user === null) {
logOff();
swal({
type: 'error',
title: 'Por favor, efetue login novamente',
text: 'Sua sessão expirou!'
});
window.location.href = '/login';
throw new Error('Sua sessão expirou');
}
try {
return JSON.parse(user) as UserData;
} catch (error) {
logOff();
swal({
type: 'error',
title: 'Por favor, efetue login novamente',
text: 'Sua sessão expirou!'
});
window.location.href = '/login';
throw error;
}
};
示例3: Swal
msg(type: any, title: any) {
return Swal({
type: type,
title: title,
showConfirmButton: false,
timer: 1500
});
}
示例4: show
private show(msg: string, options: SweetAlertOptions) {
console.warn(msg);
return swal({
html: msg,
...options
});
}
示例5: prettyPrompt
prettyPrompt(title,
text,
inputValue,
event_type,
data,
callback) {
swal({
title: title,
text: text,
//type: 'input',
input: 'email',
showCancelButton: true,
inputValue: inputValue
}).
then(
callback(event_type, data)
)
}
示例6: changeClientByDialog
changeClientByDialog(client_id) {
swal({
title: 'Are you sure want to change Client?',
type: 'info',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, change it!'
}).then(() => {
this.setDefaultClientId(client_id);
}, (dismiss) => {
if (dismiss === 'cancel') {
}
});
}
示例7: removeUser
removeUser(id: string) {
Swal({
title: 'Are you sure?',
text: 'You won\'t be able to revert this!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then(result => {
this.userService.removeUser(id).subscribe(
ok => {
Swal('Deleted!', 'Your file hs been deleted.', 'success');
},
err => {
Swal('Error!', 'User not found.', 'error');
}
);
});
}
示例8: prettyConfirm
prettyConfirm(title, text, data, callback,cancel?) {
swal(
{
title: title,
text: text,
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55'
}
).then(
(result) => {
if(result.value) {
callback(data)
}
else {
if(cancel) {
cancel(data)
}
}
}
)
}
示例9: Swal
err => {
Swal('Error!', 'User not found.', 'error');
}