【发布时间】:2017-01-30 03:38:32
【问题描述】:
我正在尝试做的是,使用 npm 类型在我的新项目中安装 typescript jquery 和 boostrap 定义文件。
以下是我遵循的步骤。
1- 打开 cmd 并转到我当前的项目文件夹并键入以下命令。
npm install typings --global
输入初始化
typings install dt~jquery --global --save
typings install dt~boostrap --global --save
2- 下面是我的 tsconfig 文件配置
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"rootDir": "./TS",
"outDir": "./JS",
"watch": true
}
}
注意:我为 TS 文件和 JS 文件创建了单独的文件夹。所以当 typescript transpile 时,它会在 JS 目录中创建 javascript 文件。
3- 在ts文件中添加document.ready函数并在页面加载时写入警报
4- 构建并运行 index.html 文件
注意:我在 head 部分添加了 transpile javascript,因此这里无需提及任何代码。
错误: 在浏览器控制台窗口中,它显示以下错误:
myscript.ts:2 Uncaught ReferenceError: $ is not defined
这是我的repository。
请帮帮我。我在我的项目中安装 jquery 做错了什么。
【问题讨论】:
标签: jquery typescript twitter-bootstrap-3 npm typescript-typings