在 Angular 18 中創建應用程式
在本文中,我們將研究創建一個新的 Angular 18 應用程式。
Angular 文件建議全域安裝 ng:
angular.dev/tools/cli/setup-local#install-the-angular-cli
sudo npm install -g @angular/cli
執行指令後:
ng new buy-and-fly
值得注意的是,這並沒有明顯的必要。您可以從應用程式本身使用 ng,您需要在啟動之前新增yarn(npm)。
要建立一個項目,只需 npx 就足夠了。
npx -p @angular/cli ng new buy-and-fly
沒有全域 CLI,一切都是一樣的。
產生了以下檔案:
buy-and-fly ├── angular.json ├── package.json ├── package-lock.json ├── public │ └── favicon.ico ├── README.md ├── server.ts ├── src │ ├── app │ │ ├── app.component.html │ │ ├── app.component.scss │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.config.server.ts │ │ ├── app.config.ts │ │ └── app.routes.ts │ ├── index.html │ ├── main.server.ts │ ├── main.ts │ └── styles.scss ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json
為了方便起見,讓我們建立一個 git 流:
git flow init
如果您沒有 gitflow 軟體包,您可以安全地跳過此步驟。
讓我們創造一個新的早午餐:
git flow feature start config-workspace
然後刪除package-lock.json:
rm package-lock.json
由於我更喜歡紗線,所以讓我們製作預設紗線:
yarn set version stable
更多關於yarn的資訊請造訪官方網站-yarnpkg.com
由於 pnpm 仍然會造成問題,為了簡單起見,我們將使用標準的 nodeLinker:
yarn config set nodeLinker node-modules
刪除 npm 安裝的依賴項:
rm -rf node_modules
為了不用費心選擇在哪裡新增供應商,讓我們將依賴項和 devDependency 結合起來。
結果,我們得到以下package.json:
{ "name": "buy-and-fly", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", "serve:ssr:buy-and-fly": "node dist/buy-and-fly/server/server.mjs" }, "private": true, "devDependencies": { "@angular-devkit/build-angular": "^18.0.5", "@angular/animations": "^18.0.4", "@angular/cli": "^18.0.5", "@angular/common": "^18.0.4", "@angular/compiler": "^18.0.4", "@angular/compiler-cli": "^18.0.4", "@angular/core": "^18.0.4", "@angular/forms": "^18.0.4", "@angular/platform-browser": "^18.0.4", "@angular/platform-browser-dynamic": "^18.0.4", "@angular/platform-server": "^18.0.4", "@angular/router": "^18.0.4", "@angular/ssr": "^18.0.5", "@types/express": "^4.17.21", "@types/jasmine": "~5.1.4", "@types/node": "^20.14.8", "express": "^4.19.2", "jasmine-core": "~5.1.2", "karma": "~6.4.3", "karma-chrome-launcher": "~3.2.0", "karma-coverage": "~2.2.1", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "rxjs": "~7.8.1", "tslib": "^2.6.3", "typescript": "~5.4.5", "zone.js": "~0.14.7" }, "packageManager": "yarn@4.3.1" }
從儲存庫中排除 .gitignore 中產生的檔案:
# Custom .yarn .angular *.patch .husky/* junit.xml /junit .env package-lock.json yarn.lock .nx src/i18n/source.xlf
安裝依賴項:
yarn
向 git 新增變更:
git add .
提交:
git commit -m “[workspace] Change package manager”
在下一篇文章中,我們將設定 linter 和 IDE。
連結
所有來源都在 github 上的儲存庫 - github.com/Fafnur/buy-and-fly
您可以在這裡觀看示範 - buy-and-fly.fafn.ru/
我的群組:telegram、medium、vk、x.com、linkedin、site
以上是在 Angular 18 中創建應用程式的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

JavaScript是現代Web開發的基石,它的主要功能包括事件驅動編程、動態內容生成和異步編程。 1)事件驅動編程允許網頁根據用戶操作動態變化。 2)動態內容生成使得頁面內容可以根據條件調整。 3)異步編程確保用戶界面不被阻塞。 JavaScript廣泛應用於網頁交互、單頁面應用和服務器端開發,極大地提升了用戶體驗和跨平台開發的靈活性。

Python和JavaScript開發者的薪資沒有絕對的高低,具體取決於技能和行業需求。 1.Python在數據科學和機器學習領域可能薪資更高。 2.JavaScript在前端和全棧開發中需求大,薪資也可觀。 3.影響因素包括經驗、地理位置、公司規模和特定技能。

學習JavaScript不難,但有挑戰。 1)理解基礎概念如變量、數據類型、函數等。 2)掌握異步編程,通過事件循環實現。 3)使用DOM操作和Promise處理異步請求。 4)避免常見錯誤,使用調試技巧。 5)優化性能,遵循最佳實踐。

實現視差滾動和元素動畫效果的探討本文將探討如何實現類似資生堂官網(https://www.shiseido.co.jp/sb/wonderland/)中�...

如何在JavaScript中將具有相同ID的數組元素合併到一個對像中?在處理數據時,我們常常會遇到需要將具有相同ID�...

JavaScript的最新趨勢包括TypeScript的崛起、現代框架和庫的流行以及WebAssembly的應用。未來前景涵蓋更強大的類型系統、服務器端JavaScript的發展、人工智能和機器學習的擴展以及物聯網和邊緣計算的潛力。

深入探討console.log輸出差異的根源本文將分析一段代碼中console.log函數輸出結果的差異,並解釋其背後的原因。 �...
