框架 :
學習資料:
- angularjs中文資料: http://www.angularjs.cn/tag/AngularJS
- angularjs API: https://docs.angularjs.org/api
- uiRouter學習資料: https://github.com/angular-ui/ui-router/wiki
- uiRouter API: http://angular-ui.github.io/ui-router/site/#/api/ui.router
組件庫
交互組件: dcloud.mui
樣式組件: mui
學習資料:
- dcloud 交互范例:http://www.dcloud.io/hellomui/
項目git地址:
git@gitlab.com:feirpri/styleplus.git
目前就只有個示例
如何啟動?Steps:
- 安裝node
- cd server
- npm install
- node index
- 訪問http://localhost:803
目錄結(jié)構(gòu):
+ public
+ platform // 平臺資源
+ js
- boot.js // 框架
- styleplus.js // 組件封裝
- index.html // 前端入口文件
+ lib // 前端公共資源
+ modules // 平臺的模塊資源,手藝人/門店/客戶
+ consumer // 客戶模塊
+ index // 模塊的子頁面
- index.js // 子頁面控制器,**文件名是固定的**
- index.html // 子頁面入口模板文件, **文件名固定**
- layout.html // 模塊入口模板文件,**必要**
- layout.js // 模塊子頁面注冊器,**必要**
+ ...
補充說明:
什么是模塊(modules)?
手藝人/門店/客戶 分別為一個模塊
如何創(chuàng)建模塊(示例: newmodule)?
- boot.js中modules變量加入新的模塊名newmodule
- modules目錄下新建文件夾newmodule
- newmodule目錄下layout.html,layout.js為模塊入口,必要。
給模塊添加子頁面(示例: stat)
1.newmodue 目錄下創(chuàng)建文件夾: stat
2.新建模板文件: index.html
3.新建模板控制器: index.js
4.在模塊的layout.js中注冊子頁面 app.registerState('newmodule.stat');
- 然后子頁面的地址就是:/#/newmodule/stat
- 如果子頁面還有子頁面(test),那么在stat文件中創(chuàng)建子目錄test,并新建index.js+index.html,子頁面層級不限。
- 其它模板文件,通過/module/newmodule/...訪問,隨意創(chuàng)建,不做限定,但是開發(fā)過程中盡量形成統(tǒng)一的規(guī)范。
資源訪問路徑
- 平臺資源: /index.html,/js/boot.js等
- 前端組件資源: /lib/...
- 模塊資源: /module/...
代碼規(guī)范:
- 使用'use strict'啟用js嚴格模式
- 使用閉包,避免創(chuàng)建全局變量
- 代碼要求通過jshint檢查
- 發(fā)布用的版本,刪掉console命令
- {}前不要折行,末尾的分號是必要的
- 縮進使用4個空格(不是2個空格,也不是tab鍵)
- 優(yōu)化http://www.mahaixiang.cn/znseo/1056.html
- 開發(fā)中的一個注意事項: angular的ngHref指令與uiSref指令有區(qū)別,前者改變地址欄,后者僅切換頁面但不改變地址欄
其它規(guī)范遵循:
http://google.github.io/styleguide/javascriptguide.xml
其它前端學習資源/工具
- 瀏覽器兼容性查詢:http://caniuse.com/
- 前端優(yōu)化及學習資源:https://developers.google.com/web/fundamentals/performance/?zh-cn
- 前端參考手冊:https://developer.mozilla.org/en-US/docs/Web/API