【发布时间】:2018-08-16 05:01:03
【问题描述】:
我正在尝试在新的 angular 4 应用中使用 bootstrap 3.3.7 弹出框组件(我不能使用 ng 版本),所以我已经安装了:
npm install --save jquery @types/jquery bootstrap
然后我将 css 和脚本添加到 angular-cli.json
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/bootstrap-tour/build/css/bootstrap-tour.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/bootstrap/dist/js/bootstrap.js",
"../node_modules/bootstrap-tour/build/js/bootstrap-tour.js"
]
然后在typings.d.ts文件中我添加了一个接口:
interface Jquery {
popover(...any) : any;
}
然后在我的组件中我导入了 jQuery:
import * as $ from "jquery"
但是当我尝试执行 popover 方法时出现编译错误:
('#test1').popover('show'); //here i have a compilation error on the popover method.
如何让打字稿识别?
【问题讨论】:
-
npm install --save jquery @types/jquery bootstrap- 很明显也安装了@types/bootstrap。你试过了吗?
标签: angular typescript