(二)、Angular4.0 开发准备

本文介绍如何在Angular项目中引入Bootstrap和jQuery,并确保TypeScript兼容。步骤包括使用npm安装必要的包、配置angular-cli.json文件、生成组件以及检查TypeScript版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、项目根目录下

npm install jquery --save

二、项目根目录下

npm install bootstrap --save

三、往项目中加入bootstrap.css,在angular-cli.json中 apps -> styles 数组里面添加字符串

  "../node_modules/bootstrap/dist/css/bootstrap.css"

       往项目中加入jquery.js、bootstrap.js,在angular-cli.json中 apps -> scripts 数组里面添加字符串

  "../node_modules/jquery/dist/jquery.js",
  "../node_modules/bootstrap/dist/js/bootstrap.js"

        


四、安装 typescript<->jquery、typescript<->bootstrap 两个类型描述文件,是的typescript认识jquery和bootstrap的代码

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

五、使用angular命令行工具来生成 6个组件

ng g component navbar
ng g component footer
ng g component search
ng g component carousel
ng g component product
ng g component stars

六、查看typescript版本是否太低,进入node_modules/typescript/package.json 查看版本号,否则node_modules/@types/xxx/index.d.ts中会报错,项目的typescript版本要比index.d.ts中的typescript版本高


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值