我使用包管理器控制台来安装这两个包:万无一失的& amp; MvcExtentions.Foolproof。我在我的bundle配置中包含了这些万无一失的脚本文件(见下文)。
请注意,我还没有实现任何万无一失的代码,我只安装了pacakges并包含了脚本文件,然后运行了应用程序。
我收到以下客户端错误:
MvcFoolproofValidation.js:未捕获的ReferenceError:未定义系统
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*",
"~/Scripts/MvcFoolproofJQueryValidation.js",
"~/Scripts/mvcfoolproof.unobtrusive.js",
"~/Scripts/MvcFoolproofValidation.js"));
呈现为:(如果有任何后果)
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="/Scripts/jquery-ui-1.10.3.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/MvcFoolproofJQueryValidation.js"></script>
<script src="/Scripts/mvcfoolproof.unobtrusive.js"></script>
<script src="/Scripts/MvcFoolproofValidation.js"></script>
答案 0 :(得分:4)
问题是因为订单不正确。我有同样的问题,但我决定这样做:
软件包:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.min.js",
"~/Scripts/blur.js"));
bundles.Add(new ScriptBundle("~/bundles/mvcfoolproof").Include(
"~/Scripts/MicrosoftAjax.js",
"~/Scripts/MicrosoftMvcAjax.js",
"~/Scripts/MicrosoftMvcValidation.js",
"~/Scripts/MvcFoolproofJQueryValidation.min.js",
"~/Scripts/MvcFoolproofValidation.min.js",
"~/Scripts/mvcfoolproof.unobtrusive.min.js"));
观点:
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/mvcfoolproof")
渲染:
<script src="/Scripts/jquery-ui-1.11.1.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="/Scripts/MicrosoftAjax.js"></script>
<script src="/Scripts/MicrosoftMvcAjax.js"></script>
<script src="/Scripts/MicrosoftMvcValidation.js"></script>
<script src="/Scripts/MvcFoolproofJQueryValidation.min.js"></script>
<script src="/Scripts/MvcFoolproofValidation.min.js"></script>
<script src="/Scripts/mvcfoolproof.unobtrusive.min.js"></script>
而且......它已经消失了。
请参阅文档以查看此订单here。
答案 1 :(得分:0)
你没有加载所有3个脚本吗?你只应加载:
mvcfoolproof.unobtrusive.js AND(MvcFoolproofJQueryValidation.js或MvcFoolproofValidation.js)
如果要加载所有3个脚本,可以停止加载MvcFoolproofValidation.js脚本。
如果你只是使用mvcfoolproof.unobtrusive.js和MvcFoolproofValidation.js,你可以换成mvcfoolproof.unobtrusive.js和MvcFoolproofJQueryValidation.js