Angular2/TypeScript中的Jquery轮播方法错误 [英] Jquery carousel method error in Angular2/typescript

查看:109
本文介绍了Angular2/TypeScript中的Jquery轮播方法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了jquery并正确导入了它.

I have installed jquery and imported it properly.

在我的应用程序中的某处,我有一行,如下所示,

Somewhere in my app, I have a line as below,

 $('#myCarousel').carousel("next");

当我执行 npm start 时,它抛出以下错误

When I do npm start, it throws below error

类型"JQuery"上不存在属性轮播".

Property 'carousel' does not exist on type 'JQuery'.

在Typescript中是否执行 $('#myCarousel').,**显示适当的**智能,但未列出此方法.

in Typescript if do $('#myCarousel')., ** it shows appropriate **intellisense but this method is not listed.

如果我注释该错误生成行,请执行 npm start ,然后一切正常,然后,如果我取消注释该行并刷新它,那么它将起作用.

If I comment that error generating line, do npm start everything works and then if I uncomment that line and refresh it, it will work.

它是一个打字稿编译错误.如何解决???

Its a typescript compiling error. How to resolve it????

推荐答案

Angular的最终版本发布后,

1)添加以下 npm个软件包

  npm install --save-dev @types/jquery
  npm install --save-dev @types/bootstrap

tsconfig.json 中的

2),在 types数组中添加以下条目,

2) in tsconfig.json add following entries in types array,

  "types": [
             "jquery",
             "bootstrap",  
           ]

现在你很好.

这篇关于Angular2/TypeScript中的Jquery轮播方法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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