◆◆◆Angular2学习笔记-问题解决方法
来源:互联网 发布:方块导航网源码 编辑:程序博客网 时间:2024/06/03 19:52
❖❖淘宝镜像❖❖
淘宝 NPM 镜像 https://npm.taobao.org/
1、设置淘宝镜像
安装:命令提示符执行npm install cnpm -g --registry=https://registry.npm.taobao.org
; 注意:安装完后最好查看其版本号cnpm -v或关闭命令提示符重新打开,安装完直接使用有可能会出现错误;
注:cnpm跟npm用法完全一致,只是在执行命令时将npm改为cnpm(以下操作将以cnpm代替npm)。
2、取消淘宝镜像/切换镜像
❖How to configure yarn to use private registry ?
https://www.npmjs.com/package/nrm
Install
$ npm install -g nrmExample
$ nrm ls* npm ----- https://registry.npmjs.org/
cnpm ---- http://r.cnpmjs.org/
taobao -- https://registry.npm.taobao.org/
nj ------ https://registry.nodejitsu.com/
rednpm -- http://registry.mirror.cqupt.edu.cn
skimdb -- https://skimdb.npmjs.com/registry
$ nrm use cnpm //switch registry to cnpm
Registry has been set to: http://r.cnpmjs.org/
Usage
Usage: nrm [options] [command]Commands:
ls List all the registries
use <registry> Change registry to registry
add <registry> <url> [home] Add one custom registry
del <registry> Delete one custom registry
home <registry> [browser] Open the homepage of registry with optional browser
test [registry] Show the response time for one or all registries
help Print this help
Options:
-h, --help output usage information
-V, --version output the version number
3、Angular2的包管理
设置以后Angular2的所有包都从cnpm下载。
命令 :ng set --global packageManager=cnpm
4、Angular2项目中如何导入第三方库
5、如何解决ng init报错
ng init --name=XXX会报错。
The specified command init is invalid. For available options, see `ng help`
出错环境
node:v6.11.2
npm:3.10.10
angular/cli:1.3.2
webstorm:2016.3.2
解决办法 :更新WebStorm版本
webstorm:2017.2.2
6、Angular2中如何传递多个参数
方法1:
→路由定义:
const routes: Routes = [ { path: '', redirectTo: '/goodsList', pathMatch: 'full' },{ path: 'goodDetail/:id/:kbn', component: GoodDetailComponent }];
→参数设置:
gotoDetail(good: Good): void { this.router.navigate(['/goodDetail', {id: good.id, kbn: 'H'}]);}
→参数获取:
ngOnInit(): void { console.log('GoodDetailComponent>ngOninit'); this.router.paramMap .switchMap((parms: ParamMap) => this.goodsService.getGoodById(+parms.get('id'), parms.get('kbn'))) .subscribe(good => this.good = good);}
方法2:
→路由定义:
const routes: Routes = [ { path: '', redirectTo: '/goodsList', pathMatch: 'full' },{ path: 'goodDetail', component: GoodDetailComponent }];
→参数设置:
gotoDetail(good: Good): void {this.router.navigate(['/goodDetail'], {queryParams: {id: good.id, kbn: 'H'}});}
→参数获取:
ngOnInit(): void { this.router.queryParamMap .switchMap((parms: ParamMap) => this.goodsService.getGoodById(+parms.get('id'), parms.get('kbn'))) .subscribe(good => this.good = good);}
阅读全文
0 0
- ◆◆◆Angular2学习笔记-问题解决方法
- Angular2学习笔记2
- Angular2 学习笔记
- angular2.0学习笔记
- angular2 学习笔记 1
- angular2学习笔记 2
- angular2 学习笔记3
- angular2学习笔记
- angular2学习笔记
- Angular2学习笔记
- Angular2学习笔记1
- angular2学习笔记(1)
- angular2学习笔记(2)
- angular2学习笔记(3)
- angular2学习笔记(4)
- angular2学习笔记(5)
- angular2学习笔记(6)
- angular2学习笔记(7)
- HTML 做一个求职简历表
- WEB基础:HTML
- 整理几个前端遇到的问题
- python引包以及pyCharm运行scrapy方法
- 关于json
- ◆◆◆Angular2学习笔记-问题解决方法
- μCOS 系列专题—分配优先级(Assigning Task Priorities)
- zookeeper-crud
- 使用httpclient发送get/post请求
- 绝对路径和相对路径
- 树莓派之蓝牙编程
- 字符设备驱动-LED驱动
- activiti全局的监听器和链接监听器
- C++项目中的extern "C" {}