angular-datatables ReferenceError:未使用Dot Net Core Angle 4模板定义$ [英] angular-datatables ReferenceError: $ is not defined using Dot net core angular 4 template

查看:65
本文介绍了angular-datatables ReferenceError:未使用Dot Net Core Angle 4模板定义$的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Studio模板创建了一个具有点网核心应用程序的Angular 4.我想在我的应用程序中使用数据表,并尝试使用 https://l-lin.github.io/angular-datatables/#/getting-started 但是我收到错误::ReferenceError:$未定义.我试图将import *用作来自"jquery"的$;但是没有用.请指教.谢谢.

I have created a Angular 4 with dot net core application using visual studio template. I want to use datatables in my app and tried to follow steps using https://l-lin.github.io/angular-datatables/#/getting-started But I received error as : ReferenceError: $ is not defined. I tried to use import * as $ from "jquery"; But did not work. Please advice. Thank you.

推荐答案

您不能遵循 https://l-lin.github.io/angular-datatables/#/getting-started 适用于.Net Core-Angular应用程序.该设置需要 .angular_cli.json ,并且由于您未使用 ng serve ,因此无法正常工作.

You can't follow https://l-lin.github.io/angular-datatables/#/getting-started for a .Net Core - Angular Application. The setup requires .angular_cli.json and since you're not using ng serve, it will not work that way.

可能您可以在ASP .NET index.cshtml 文件上添加CDN .js包:

Possibly you can add CDN .js packages on your ASP .NET index.cshtml file:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" type="text/javascript"></script>

并在 _Layout.cshtml 文件上添加CSS:

And add css on your _Layout.cshtml file:

<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" />

请检查并告知我们是否可行.祝你好运.

Please check and let us know if that works. Good Luck.

这篇关于angular-datatables ReferenceError:未使用Dot Net Core Angle 4模板定义$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆