我正在使用sweet-alert插件来显示警报.使用经典配置(默认值),一切正常.但是当我想在TEXT中添加HTML标签时,它会显示<b>...</b>
而不会使其变为粗体.在搜索答案后,看起来我没有正确的搜索词......
如何使用HTML代码制作甜蜜警报显示文本?
var hh = "<b>test</b>";
swal({
title: "" + txt + "",
text: "Testno sporocilo za objekt " + hh + "",
confirmButtonText: "V redu",
allowOutsideClick: "true"
});
Run Code Online (Sandbox Code Playgroud) 我喜欢这个图书馆.我想用它在我的一个网页上显示一个温和的响应表,但文本有点宽.我希望有一个选项来改变我在SweetAlert中显示表格的页面的整体警报的宽度,但我没有运气.表和HTML看起来很棒,对于模态来说太多了.
我甚至无法找到整体sweetalert.css中设置宽度的位置.
我想也许customClass配置键可能有帮助,我试过:
swal({
title: priorityLevel +' Issues for '+appName,
html: appHTML,
type: "info",
customClass: 'swal-wide',
showCancelButton: true,
showConfirmButton:false
});
Run Code Online (Sandbox Code Playgroud)
css只是一个简单的:
.swal-wide{
width:850px;
}
Run Code Online (Sandbox Code Playgroud)
这没有做任何事情.任何人都知道如何做到这一点,或者可能已经玩过宽度元素?
谢谢!
我能够在页面刷新后显示甜蜜的警报,但是我必须单击"确定"按钮,我将获得甜蜜警报以重定向页面.请帮助我.
<?php
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal("WOW!","Message!","success");';
echo '}, 1000);'
echo 'window.location.href = "index.php";';
echo '</script>';
?>
Run Code Online (Sandbox Code Playgroud) 我正在使用javascript甜蜜警报库:
https://limonte.github.io/sweetalert2/
https://github.com/limonte/sweetalert2
我想从警告框中删除"确定"按钮,但我没有找到任何不显示此按钮的属性.
我正在使用timer属性timer:1000
在一秒钟内关闭警报.所以,我认为在这件事上没有使用ok按钮.
我正在使用"Sweet Alert"在我的产品视图中弹出一个带有两个按钮的电子商务应用程序中的弹出窗口; 一个用于进入购物车视图,另一个用于重新加载视图.
但是当用户在弹出窗口外单击时,弹出窗口会自动关闭.我试过跟随属性来阻止它被关闭但没有任何效果
__CODE__
__CODE__
__CODE__
__CODE__
任何帮助/建议都非常感谢.谢谢.
我试图在API返回错误时显示警报。对于警报窗口,我正在使用sweetalert2。在我的渲染方法中,我正在检查错误消息是否包含内容。如果包含错误消息,我想向用户显示警报。
提交表单时,我会进行API调用。如果返回错误,则reducer更改存储(状态),并再次呈现页面。
由于我添加了以下行,因此我不断收到错误消息:
{saveLabelFetchError && this.toggleAlertFailure(saveLabelFetchError)}
Run Code Online (Sandbox Code Playgroud)
错误:
index.js:1375警告:unable_flushDiscreteUpdates:React已经渲染时无法刷新更新。
我的组件:
{saveLabelFetchError && this.toggleAlertFailure(saveLabelFetchError)}
Run Code Online (Sandbox Code Playgroud)
我想知道为什么我总是在控制台中收到此错误消息。
在角度项目中的npm开始后获取此错误.
app/app.component.ts(12,7):错误TS2304:找不到名称'swal'.app/app.component.ts(21,7):错误TS2304:找不到名称'swal'.
我创建了一个角度项目.在app.component.ts里面我添加了甜蜜的警报代码
export class AppComponent {
deleteRow() {
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(function() {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
);
})
}
}
Run Code Online (Sandbox Code Playgroud)
我做到了
npm install sweetalert2 --save
Run Code Online (Sandbox Code Playgroud)
并在index.html中添加了路径
<script src="node_modules/sweetalert2/dist/sweetalert2.min.js"></script>
<link rel="stylesheet" type="text/css" href="node_modules/sweetalert2/dist/sweetalert2.css">
Run Code Online (Sandbox Code Playgroud) 如何在使用promises时正确转义取消按钮而不会抛出错误?我的代码会抛出一个带有必填复选框的警报确认.代码应该对用户执行,但它会在控制台窗口中引发错误:
未被捕(承诺)取消
//validation logic all passes...Now proceed to...
else
{
//determine and parse Discounts
var myLookup = document.getElementsByName("myLookup")[0].value;
$.post( "findthem.php", {myLookup: myLookup })
.done(function(json_data){
var theResponse1 = $.parseJSON(json_data);
myDiscountRate = theResponse1['ourDiscountFound'];
}).then( function(callback){
priceRate = priceRate * (1 - (.01 * myDiscountRate));
newRate = priceRate.toFixed(2);
}
swal({
title: "Confirm",
input: 'checkbox',
inputValue: 0,
type: "warning",
inputPlaceholder: 'I agree to <a href="#blahblahMore"></a> Your new Rate is :'+newRate,
showCancelButton: true,
confirmButtonText: 'Confirm',
showLoaderOnConfirm: true,
preConfirm: function(result) {
return new Promise(function(resolve, reject) { …
Run Code Online (Sandbox Code Playgroud) 我正在尝试更改取消按钮的颜色,就像我可以为确认按钮,但它似乎没有工作由于某种原因.
(参见https://jsfiddle.net/x20ra1o1/))
代码是:
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
cancelButtonColor: "#DD6B55",
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel please!",
closeOnConfirm: false,
closeOnCancel: false
}, function (isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
Run Code Online (Sandbox Code Playgroud) 我在将 javascript 变量加载到引导程序模型输入框中时遇到了一些问题:
setTimeout(function() {
swal({
title: "OverTime Status!",
text: "You Need to get Sub OT Approval " + data.value + " Hours to Time allocate in the department",
type: "warning",
confirmButtonText: "OK"
},
function(isConfirm) {
if (isConfirm) {
$('#hours_work').val(data.value); //data.value alert the correct value in here.but this value not load in to the bootstrap model text box
$('#overtime_requset').modal('show');
clear_field();
}
});
}, 1);
Run Code Online (Sandbox Code Playgroud)
<div class="modal" id="overtime_requset">
<div class="modal-dialog ">
<form id="overtime_requset_form">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header"> …
Run Code Online (Sandbox Code Playgroud)javascript ×10
sweetalert ×10
jquery ×3
sweetalert2 ×3
ajax ×1
angular ×1
css ×1
html ×1
input ×1
php ×1
reactjs ×1
typescript ×1