这个给我一个@question
这里有什么问题?
@{
string question = "Really delete?";
<link href="~/Content/sweetalert/sweetalert.css" rel="stylesheet" />
<script src="~/Content/sweetalert/sweetalert.min.js"></script>
<script>
$(function () {
$(".delete").on("click", function (e) {
swal({
text: @question,
title: "Delete Confirm",
//some other stuff...
}
答案 0 :(得分:0)
您必须以这种方式使用question
:
title: "@question"
代码:
@{
string question = "Really delete?";
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<link href="~/Content/sweetalert.css" rel="stylesheet" />
<script src="~/Content/sweetalert.min.js"></script>
<script>
$(function() {
$(".delete").on("click", function(e) {
swal({
title: "@question",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
});
});
});
</script>
}
答案 1 :(得分:0)
text: @question
应该包含在''
中,如此
text: '@question'