2018年11月24日 星期六

[Day5]用VS Code對react.js不友善

Github: https://github.com/ShawnTseng/react-for-fun/commit/8388043fd166323872cab7aa17bfe8028a3b7981

今天假日用自己的筆電開啟vscode寫react,排版時(Shift + Alt + F),整個亂掉無法執行,因此作了以下調整:
1.安裝套件
npm install babel-eslint eslint-plugin-jsx-a11y eslint-plugin-react --save-dev
npm install prettier-eslint --save-dev
2.設定vscode/settings.json
// Format a file on save.
// A formatter must be available,
// the file must not be auto-saved,
// and editor must not be shutting down.
"editor.formatOnSave": true,

// Enable/disable default JavaScript formatter (For Prettier)
"javascript.format.enable": false,

// Use 'prettier-eslint' instead of 'prettier'.
// Other settings will only be fallbacks
// in case they could not be inferred from eslint rules.
"prettier.eslintIntegration": true
3.將副檔名js改成jsx
3-1.匯入檔案時的副檔名也要記得改

2018年11月23日 星期五

[Day4]React 練習

原始碼: https://github.com/ShawnTseng/react-for-fun

Angular學得滿完整的,在自學react的過程中,有非常多概念可以共用,目前把 React的 props, state, Component開發, validate, CRUD實作過了。
目前進入到Flux整個概念的了解與熟悉。

參考資料:
https://github.com/shiningjason/react-quick-tutorial

2018年11月22日 星期四

[Day3]Angular i18n part1

功能目的: 讓Web應用程式國際化 - 讓世界各地的使用者有友善的體驗
開始前的兩種概念建立:
  1. 國際化 - 讓應用程式支援多種語系
  2. 在地化 - 讓國際化的應用程式,進入特定的語言環境
國際化總共做4件事情:
  1. 日期、數量、百分比、貨幣可轉換成各國格式
  2. 一般文字的翻譯
  3. 單字的單複數處理
  4. 翻譯HTML屬性的替代文字
在地化 - 藉由angular cli產生在地的應用程式

angular在地化的概念是在建置(Build)的過程中實現的,所以分為兩種情境
  1. JIT(Just In Time)
  2. AOT(Ahead Of Time)
  • JIT加入i18n概念的作法
在根模組(AppModule)中註冊LOCALE_ID
  • AOT的作法 - 使用angular cli指令佈署
ng serve --i18nFile=path --i18nFormat=xlf --i18nLocale=fr
ng build --i18nFile=path --i18nFormat=xlf --i18nLocale=fr
--i18nFile: 多國語系檔案路徑
--i18nFormat: 檔案格式
--i18nLocale: 語系名稱

以上是在地化的處理,明天寫以下兩件事
  1. 研究國際化的具體實作細節
  2. 補上在地化的範例程式碼

未完待續...