前端笔记

l  npm 指令在package.json的scripts字段中写。concurrently插件可以为start字段配多个任务。

l  在项目中局部引用jquery的。const $ = require('jquery');

l  引用公共设置:

 

l  bootstrapTable 样式拓展:

 

l  Ubantu上把其它人本地仓库设为远程库的方法:

git remote add shenjunjie root@10.63.244.253:/root/code/Uniportal   

git fetch shenjunjie

git checkout --track shenjunjie/master0204    获取对方的分支号

l  git checkout -b VDC2-V5.16.11 origin/VDC2-V5.16.11 在本地创建一个远程分支.

l  项目mock打桩用的是node的restify框架。

l  http-server         webpack-dev-server插件。

l  代码如果走不到,注意是不是异步事件。

l  git review 提交代码

git add -A

git commit -s -m "commit msg"

git review -R

l   angular2 ngmodle绑定变量一组input时不能同时渲染问题:在每个input内加一个[ngModelOptions]="{standalone: true}"属性。

l   angular2样式是否封装于组件中(避免污染其它组件)。取决于encapsulation属性的如果是ViewEncapsulation.None则不封装保护

url:http://www.codesec.net/view/484989.html

@Component({

         selector: 'todo-item',

         templateUrl: 'app/todo/item/item.component.html',

         styleUrls: ['app/todo/item/item.component.css'],

         styles: ['.completed{background:lightblue;}'],

         encapsulation: ViewEncapsulation.Emulated

 })

export class TodoItemComponent{ ... }

l   深拷贝对象

function cloneObject(obj){

   var o = obj instanceof  Array ? [] : {};

   for(var i in obj){

       if(obj.hasOwnProperty(i)){

                           o[i] = typeof obj[i] === "object" ? cloneObject(obj[i]) : obj[i];

                            }

                     }

              }

 

l   获取字符串字节数的方法:

getLength : function(str) { 

        var realLength = 0, len = str.length, charCode = -1; 

        for ( var i = 0; i < len; i++) { 

            charCode = str.charCodeAt(i); 

            if (charCode >= 0 && charCode <= 128) 

                realLength += 1; 

            else 

                realLength += 2; 

        } 

        return realLength; 

    };

l   Rxjs返回的是一个observable对象,需要用toPromise()方法转化为promise对象。

posted @ 2017-03-29 08:59  CN-Tower  阅读(181)  评论(0)    收藏  举报