[关闭]
@duanyubin 2015-11-03T01:55:27.000000Z 字数 1249 阅读 284

Boilerplate

javascript


Boilerplate

  1. 3g-boilerplate
  2. angular-boilerplate
  3. react-boilerplate

TODOS

  1. Upload files to sftp by gulp
  2. Redesign 3g & angular
  3. Optimize react with Reduxjs

Workflow

  1. 采用npm作为包管理工具
  2. 使用browerify和webpack进行打包
  3. 对可重用模块进行单元测试
  4. 尽量不适用原生javascript,而使用typeScript、coffeeScript、ES2015。

Newsapp-react

新闻客户端react版接口

客户端开发注意要点

ES2015

ES6要点

  1. 块级作用于
  2. 变量结构

    1. let {a, b} = {foo: foo, bar: bar}
    2. let [a, b, c] = [1, 2, 3]
    3. return {a, b}
  3. 原始数据类型的方法扩展,String Array Object

    1. let a = `${a} whatever ${b}`
    2. Array.from();
    3. Object.assign();
    4. let specialMethod = Symbol();
    5. let obj = {
    6. [specialMethod]: function(){
    7. .....
    8. }
    9. }
    10. Object.observe() Object.unobserve()
  4. 新增的原始类型

    • Symbol 每个Symbol的值都不相等
    • Proxy 在目标对象之前,增加一层拦截
  5. 函数

    • 参数默认值 function Point(x=0, y=0){...}
    • rest参数 function add(...value){}
    • Arrow Function [1, 2, 3].map(x => x * x)
  6. SET && MAP
  7. Iterator && for of
  8. Generator && Promise
  9. Class && Module

    1. class Person{
    2. constructor(name, age){
    3. this.name = name;
    4. this.age = age;
    5. }
    6. say(words){
    7. console.log(`${this.name} said ${words}`)
    8. }
    9. }
    10. class Student extends Person{
    11. constructor(name, age, grade){
    12. super(name, age);
    13. this.grade = grade
    14. }
    15. }
    16. // a.js
    17. export var str = 'hello'
    18. export function func(){}
    19. export class Person{}
    20. //b.js
    21. import {str, func, Person as P} from './a'
    22. // c.js
    23. export default class Student{}
    24. // d.js
    25. import Student from './c'
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注