jquery - 尝试将 jQuery-UI 添加到 Angular 4 应用程序时,TypeError : t. fx 未定义

标签 jquery angular jquery-ui typescript npm

我正在尝试将 jQuery-UI 添加到应用程序,因为我需要访问一些 slider 。我已经为 jQuery 安装了类型:

npm install @types/jquery --save

什么似乎是 jQuery-UI 类型

npm install @types/jqueryui --save

我已将 jQuery 和 jQuery-UI CDN 引用添加到 index.html

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>SimutronApp</title>
  <base href="/">
  <script
    src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
    integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
    crossorigin="anonymous">
  </script>
  <script
    src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
    integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
    crossorigin="anonymous">
  </script> 
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

但是,在 Firefox 中我得到错误:

t.fx is undefined     jquery-ui.min.js:6

Chrome 抛出:

cannot read property 'step' of undefined at <String>.anonymous

在同一行。谁能告诉我将 jQuery-UI 添加到 Angular 4 项目的正确方法?

最佳答案

Jquery Slim 移除了一些 Jquery UI 依赖的特性。

替换

  <script
    src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
    integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
    crossorigin="anonymous">

与:

<script src="http://code.jquery.com/jquery-3.2.1.min.js"
        integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
        crossorigin="anonymous"></script>

关于jquery - 尝试将 jQuery-UI 添加到 Angular 4 应用程序时,TypeError : t. fx 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43712113/

相关文章:

javascript - 将 javascript 转换添加到 Bootstrap Accordion

javascript - jQuery 属性 ("src") 返回未定义

javascript - jqGrid 需要 'enter' 键来执行内联编辑的验证功能

jquery - 在 UpdatePanel 中使用 JQuery UI 日期选择器

使用 JSP 和 JAVA 的 jQuery DataTables 服务器端处理

javascript - jQuery animate 在所有浏览器中都非常不稳定 - 带有 jpg 的 div 同时向上移动和淡入

angular - angular 的@Attribute 装饰器是如何工作的?

Angular2 表单重新加载而不是调用 onSubmit()

javascript - 使用 Angular 表单取消提交

jquery - global.asax 中神秘的 'File does not exist' 错误(与任何类型的文件 IO 无关的代码)