Twitter bootstrap 3 Typescript Twitter引导程序不可注入?
我试过了 而tsd.json将是Twitter bootstrap 3 Typescript Twitter引导程序不可注入?,twitter-bootstrap-3,typescript,typescript1.5,Twitter Bootstrap 3,Typescript,Typescript1.5,我试过了 而tsd.json将是 tsd install jquery --save tsd install bootstrap --save 而tsd.d.ts是 { "version": "v4", "repo": "borisyankov/DefinitelyTyped", "ref": "master", "path": "typings", "bundle": "typings/tsd.d.ts", "installed": { "jq
tsd install jquery --save
tsd install bootstrap --save
而tsd.d.ts是
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"jquery/jquery.d.ts": {
"commit": "c5a2f44bab06cf9f2bcc14530171daac1cebff6c"
},
"bootstrap/bootstrap.d.ts": {
"commit": "c5a2f44bab06cf9f2bcc14530171daac1cebff6c"
}
}
}
//
///
所以,我想我能做到
/// <reference path="jquery/jquery.d.ts" />
/// <reference path="bootstrap/bootstrap.d.ts" />
//
导入$=require('jquery');
$(“#modal”).modal();
但我有这个警告
未捕获类型错误:t(…)。模态不是函数
有什么想法吗?提供的代码示例:
/// <reference path="../../typings/tsd.d.ts" />
import $ = require('jquery');
$('#modal').modal();
工作正常提供的代码示例:
/// <reference path="../../typings/tsd.d.ts" />
import $ = require('jquery');
$('#modal').modal();
工作正常类型脚本仅用于开发时间。如果您遇到运行时问题,可能是因为您没有包含一些脚本。TypeScript仅针对开发时间。如果您遇到运行时问题,可能是因为您没有包含一些脚本。您提供的说明:
tsd安装jquery——保存
tsd安装引导程序--保存
为我工作。我的主要组件(app.component.ts
)中包含以下内容:
declare var$:JQueryStatic
我有一个情态动词的组件,我在其中使用了以下内容,没有任何抱怨:
@ViewChild(“模态”)模态:ElementRef
ngAfterViewInit(){
$(this.modal).modal()
}
我希望它对你也有用 您提供的说明:
tsd安装jquery——保存
tsd安装引导程序--保存
为我工作。我的主要组件(app.component.ts
)中包含以下内容:
declare var$:JQueryStatic
我有一个情态动词的组件,我在其中使用了以下内容,没有任何抱怨:
@ViewChild(“模态”)模态:ElementRef
ngAfterViewInit(){
$(this.modal).modal()
}
我希望它对你也有用 这应该和你写的一样,实际的错误是什么?您编写了t(…)。modal不是函数。但编译后我没有看到t(…),浏览器控制台显示以下消息uncaughttypeerror:t(…)。modal不是函数
。我想这意味着引导没有被注入jQuery:(这应该和你写的一样,实际的错误是什么?你写了t(…)。模态不是一个函数。但是我在编译后没有看到t(…),浏览器控制台显示下面的消息uncaughttypeerror:t(…).modal不是一个函数
。我想这意味着引导不会被注入到jQuery中:(你知道我应该如何将未包含的脚本包含到它中吗?:使用与将jQuery添加到项目(可能在index.html中)相同的方法,添加缺少的文件(可能是引导文件)您知道我应该如何将未包含的脚本包含到其中吗?:使用与将jquery添加到项目(可能在index.html中)相同的方法,添加缺少的文件(可能是引导文件)