几天前我开始使用Ionic 2和Angular 2,但现在当我运行" ionic start myProjectName blank --v2
"时,它总是使用v3.0.1 ionic框架创建一个新项目。即使我指定" --v2
",它也使用 Ionic 3.0.1 和 Angular 4,但我想将 Ionic 2 与 angular 2 一起使用,因为我认为现在将 Ionic 3 和 Angular 4 用于生产 Web 应用程序还为时过早。
这是我的命令"$ 离子信息"输出:
Your system information:
Cordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.10.0
Xcode version: Not installed
和我的 package.json 依赖项块:
"dependencies": {
"@angular/common": "4.0.0",
"@angular/compiler": "4.0.0",
"@angular/compiler-cli": "4.0.0",
"@angular/core": "4.0.0",
"@angular/forms": "4.0.0",
"@angular/http": "4.0.0",
"@angular/platform-browser": "4.0.0",
"@angular/platform-browser-dynamic": "4.0.0",
"@ionic-native/core": "3.4.2",
"@ionic-native/splash-screen": "3.4.2",
"@ionic-native/status-bar": "3.4.2",
"@ionic/storage": "2.0.1",
"ionic-angular": "3.0.1",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.4"
},
[编辑]我还在Ionic论坛上发布了这个问题,如果这个云帮助了其他人。非常感谢 https://forum.ionicframework.com/t/ionic-2-with-angular2/86072/2。
离子博客
据此,
使用CLI 版本 2.x 仍需要
--v2
标志才能使用最新版本的框架(当前为 3.0.1(创建应用。如果您使用的是 CLI 的测试版(3.0.0-beta.5 是最新版本(,则不需要任何标志,并且将使用最新版本的框架 (3.0.1( 生成应用。因此,使用最新的 v2 框架(我认为是 2.2.0 或 2.3.0(创建新应用程序不再可能。要么是 1。.或现在的 3.0.0。
您可以将package.json
更改为旧版本
"dependencies": {
"@angular/common": "2.4.8",
"@angular/compiler": "2.4.8",
"@angular/compiler-cli": "2.4.8",
"@angular/core": "2.4.8",
"@angular/forms": "2.4.8",
"@angular/http": "2.4.8",
"@angular/platform-browser": "2.4.8",
"@angular/platform-browser-dynamic": "2.4.8",
"@angular/platform-server": "2.4.8",
"@ionic/storage": "2.0.0",
"ionic-angular": "2.2.0",
"ionic-native": "2.8.1",
"ionicons": "3.0.0",
"rxjs": "5.0.1",
"sw-toolbox": "3.4.0",
"zone.js": "0.7.2"
},
然后运行>_ npm install