Kendo,ASP.NET Core - 未捕获的ReferenceError:未定义kendo

时间:2017-07-12 15:38:42

标签: asp.net kendo-ui

我已经开始使用Kendo + ASP.NET Core。我遵循了本教程http://docs.telerik.com/aspnet-core/getting-started/getting-started#configuration-Add,但我收到了错误:未捕获的ReferenceError:未定义kendo

HEAD

    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="/css/site.css" />
    <link rel="stylesheet" href="/lib/kendo-ui/styles/kendo.common-nova.min.css" />
    <link rel="stylesheet" href="/lib/kendo-ui/styles/kendo.nova.min.css" />

BODY

<h2>Kendo UI DatePicker</h2><input id="datepicker" name="datepicker" type="text" value="" /><script>kendo.syncReady(function(){jQuery("#datepicker").kendoDatePicker({"format":"dd.MM.yyyy","footer":false});});</script>
    <script src="/lib/jquery/dist/jquery.js"></script>
    <script src="/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="/js/site.js?v=EWaMeWsJBYWmL2g_KkgXZQ5nPe-a3Ichp0LEgzXczKo"></script>
    <script src="/lib/kendo-ui/js/kendo.all.min.js"></script>
    <script src="/lib/kendo-ui/js/kendo.aspnetmvc.min.js"></script>

1 个答案:

答案 0 :(得分:5)

如果我在ASP.NET Core中使用Kendo UI,我个人喜欢将所有这些脚本放在 head 标记内。

由于ASP.NET Core中的代码太多,我将它们保存在单独的 Partial 类中。 例如,_StylesScriptsPartial.cshtml

<environment names="Development">
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css"/>
    <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.bootstrap.min.css" />
    <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.common-bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css"/>

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
    <script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="~/lib/kendo-ui/js/kendo.all.min.js"></script>
    <script src="~/lib/kendo-ui/js/kendo.aspnetmvc.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
</environment>

_layout.cshtml内,

@await Html.PartialAsync("_StylesScriptsPartial")

另一个技巧是添加Kendo UI,因为 本地NuGet包 比手动引用DLL更容易。

Add NuGet Packages

enter image description here