我在ASP.NET CORE 1.0中遇到了一个最奇怪的问题。我的 将ASPNETCORE_ENVIRONMENT设置为Production时,JQuery不起作用。 ITS仅页面的内联jquery。所有其他jquery函数都可以正常工作。
以下是我的代码。
sub_CLI1.nested-nested_SubReport
_Layout.cshtml
$(function () {
if ($("#LeadId").val() == '') {
$("#nextButton").addClass("disabledbutton");
$("#divTerms").removeClass("ControlIsVisible");
} else {
$("#nextButton").removeClass("disabledbutton");
$("#divTerms").addClass("ControlIsVisible");
}
$('#lblCheckBox').click(function () {
var isChecked = $("#chkTerms").is(":checked");
if (isChecked === true) {
$('#lblCheckBox').removeClass("active");
$("#nextButton").addClass("disabledbutton");
}
else {
$('#lblCheckBox').addClass("active");
$("#nextButton").removeClass("disabledbutton");
}
});
$.get("http://ipinfo.io", function (response) {
$("#PersonalDetail_ActualCountry").val(response.country);
}, "jsonp");
});
答案 0 :(得分:0)
您需要在生产中添加css和脚本文件的链接。
可以直接在messages = [x for x in re.split(b'(?:\xff){8}', payload) if x]
# Or, the fastest way here as per the comments
messages = list(filter(None, messages))
_layout.cshtml
或更好<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@ViewBag.Title</title>
<environment names ="Development">
<link asp-href-include="~/css/*.css" rel="stylesheet" />
<link asp-href-include="~/css/CustomCss.css" rel="stylesheet" />
</environment>
<environment names="Staging, Production">
<link href="~/css/min/site.min.css" rel="stylesheet" />
<!-- Add this line -->
<link asp-href-include="~/css/CustomCss.css" rel="stylesheet" />
</environment>
</head>
<body>
<div>
<environment names="Development">
<script asp-src-include="~/js/jquery.js"></script>
<script asp-src-include="~/js/jquery.validate.js"></script>
<script asp-src-include="~/js/jquery.validate.unobtrusive.js"></script>
<script asp-src-include="~/js/bootstrap.js"></script>
<script asp-src-include="~/js/CustomScript.js"></script>
</environment>
<environment name="Staging, Production">
<script src="~/js/min/site.min.js"></script>
</environment>
@RenderBody()
</div>
</body>
</html>
bundlesconfig.json
答案 1 :(得分:0)
检查您发布的版本是否包含wwwroot文件夹中的site.min.js。这可以使用project.json中的“publishOptions”配置来完成:
const unprotectedRoutes = [];
const protectedRoutes = [
// protected routes here
].map((r:Route) => {
r.canActivate = (r.canActivate) ? [AuthGuard, ...r.canActivate] : [AuthGuard];
return r;
});
export const routeConfig = [...unprotectedRoutes, ...protectedRoutes];
如果您发布的文件夹包含您的site.min.js.检查您的自定义代码是否低于Jquery框架。
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
}
});