我正在尝试将jQuery-UI添加到应用程序,因为我需要访问一些滑块.我已经为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 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>