program collections
Java
byte & 0xff
byte[] b = new byte[1];b[0] = -127;System.out.println("b[0]:"+b[0]+"; b[0]&0xff:"+(b[0] & 0xff));//output:b[0]:-127; b[0]&0xff:129計算機內(nèi)二進制都是補碼形式存儲:
b[0]: 補碼,10000001(8bit)
b[0]以int輸出:int(32bit),補位1。11111111 11111111 11111111 10000001(32bit)
和原數(shù)一致
b[0]&0xff:11111111 11111111 11111111 10000001(32bit) & 11111111 =
00000000 00000000 00000000 10000001
低精度轉(zhuǎn)成高精度數(shù)據(jù)類型,有兩種擴展方案。(1)補零擴展 (2)符號位擴展
對于正數(shù)兩種是一樣的。
使用補零擴展能夠保證二進制存儲的一致性,但不能保證十進制值不變
使用補符號位擴展能夠保證十進制值不變,但不能保證二進制存儲的一致性
對于有符號類型,Java使用的是補符號位擴展,這樣能保證十進制的值不變
return break
break is used to exit (escape) the for-loop, while-loop, switch-statement that you are currently executing.
return will exit the entire method you are currently executing (and possibly return a value to the caller, optional).
inputstream byte[] to String
byte[] buffer = new byte[17];if (is != null) {int size = is.read(buffer);if(size > 0 ){String Str = new String(buffer,0,size);}}Stm32 send packet
byte[] packet = new byte[len];packet[0] = (byte) type;packet[1] = (byte) len;packet[2] = (byte) seq;packet[3] = (byte)(isreset?1:0);packet[4] = (byte) vx;packet[5] = (byte)(vx >>8);packet[6] = (byte) vy;packet[7] = (byte)(vy >>8 );// System.arraycopy(command.toDatas(), 0, packet, 3, command.getLen());int Seq = (datas[0]&0XFF);int vx = (datas[1]&0XFF) | ((datas[2])<<8));int Vy = ((datas[3]&0XFF) | ((datas[4])<<8));boolean Motostatel = ((datas[4] & (1 << 1))!=0);boolean Motostater = ((datas[4] & (1 << 2))!=0);System.arraycopy(Object src,int srcPos,Object dest,int destPos,int length)
src:源數(shù)組
srcPos:源數(shù)組起始位置
dest:目標數(shù)組
destPos:目標數(shù)組起始位置
length:長度
Tips: src和dest是要可以互相轉(zhuǎn)換或是同類型的數(shù)組
Tips:
可以自己復(fù)制自己
int[] src ={0,1,2,3,4,5,6}; System.arraycopy(src,0,src,3,3);// output:{0,1,2,0,1,2,6}生成一個長度為length的臨時數(shù)組,將fun數(shù)組中srcPos
到srcPos+length-1之間的數(shù)據(jù)拷貝到臨時數(shù)組中,再執(zhí)行System.arraycopy(臨時數(shù)組,0,fun,3,3)
new Semaphore(0)
Semaphore semaphore = new Semaphore(0);try {semaphore.acquire();} catch (InterruptedException e) {e.printStackTrace();}//semaphore.release();初始化信號量為0,semaphore.acquire()線程會阻塞。直到semaphore.release()之后 信號量變?yōu)?。
mysql
1045 access denied for user 'root'@'localhost' using password yes
忘記localhost密碼,密碼錯誤
step1,找到mysql安裝目錄下my.ini。在[mysql]下添加 skip-grant-tables
step2,重啟mysql服務(wù)
step3,以管理員身份運行 cmd. 輸入mysql -u root -p,直接回車
step4,輸入use mysql
step5,mysql 5.6以前的,輸入UPDATE mysql.user SET Password=PASSWORD('123456') WHERE User='root';
?
mysql 5.6以后的,輸入UPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE USER='root';
Android
權(quán)限
root
在linux系統(tǒng)中是只有root權(quán)限和普通權(quán)限,root即是最高權(quán)限。
Android獲取root其實和Linux獲取root權(quán)限一樣。Linux下獲取root權(quán)限的時候就是執(zhí)行sudo或者su。
Android本身就不想讓你獲得Root權(quán)限,大部分手機出廠的時候根本就沒有su這個程序。所以你想獲得Android的root權(quán)限,第一步就是要把編譯好的su文件拷貝到Android手機的/system/bin或者/system/xbin/目錄下。接下來你可以在Android手機的adb shell或者串口下輸入su了。
getColor() 過時
// 過時 textView.setTextColor(getResources().getColor(R.color.text_color));textView.setTextColor(ContextCompat.getColor(this,R.color.text_color));Installation error:INSTALL_FAILED_UID_CHANGED
嘗試通過ADB刪除產(chǎn)生沖突的數(shù)據(jù)文件
adb rm -rf /data/data/<your.package.name>setHeight no use
當設(shè)置的高度比原來默認的高度要小時,調(diào)整setHeight是不生效的。
editText=(EditText)findViewById(R.id.myEditText);// editText.setHeight(10); //不生效editText.getLayoutParams().height = 100;Installation error:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
1.1 包名大寫了
2.2 缺少AndroidManifest.xml文件
Error:Error converting bytecode to dex
1.1 包重復(fù)
2.2 build本身問題, 只需要clean and rebuild 一下
EditText光標顏色
EditText 有一個屬性 android:textCursorDrawable 用來控制光標的顏色。android:textCursorDrawable="@null","@null"作用是讓光標顏色和text color一樣
?
發(fā)現(xiàn)了以元素'd:skin'開頭的無效內(nèi)容
把有問題的devices.xml刪除,在Android SDK 里面的tool\lib 下找到devices.xml拷貝到那個文件夾。
?
finished with non-zero exit value 2
重復(fù)的jar包,刪除引用的包,同時刪除module的build.gradle文件的引用。
border
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"><solid android:color="#418bdc"/><corners android:radius="2dp"/><stroke android:width="2dp" android:color="#303f9f"/><padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" /> </shape>VideoView播放視頻無法全屏問題
重寫VideoView
import android.content.Context; import android.util.AttributeSet; import android.widget.VideoView;/*** Created by lijingnan on 12/04/2017.*/ public class CustomerVideoView extends VideoView {public CustomerVideoView(Context context) {super(context);}public CustomerVideoView(Context context, AttributeSet attrs) {super(context, attrs);}public CustomerVideoView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {// 其實就是在這里做了一些處理。int width = getDefaultSize(0, widthMeasureSpec);int height = getDefaultSize(0, heightMeasureSpec);setMeasuredDimension(width, height);} }退出程序
- KillProcess
Tips:android中所有的activity都在主進程中,在Androidmanifest.xml中可以設(shè)置成啟動不同進程,Service不是一個單獨的進程也不是一個線程。
當你Kill掉當前程序的進程時也就是說整個程序的所有線程都會結(jié)束,Service也會停止,整個程序完全退出。
- System.exit
Can't create handler inside thread that has not called Looper.prepare()
Handler對象與其調(diào)用者在同一線程中,如果在Handler中設(shè)置了延時操作,則調(diào)用線程也會堵塞。每個Handler對象都會綁定一個Looper對象,每個Looper對象對應(yīng)一個消息隊列(MessageQueue)。如果在創(chuàng)建Handler時不指定與其綁定的Looper對象,系統(tǒng)默認會將當前線程的Looper綁定到該Handler上。
在主線程中,可以直接使用new Handler()創(chuàng)建Handler對象,其將自動與主線程的Looper對象綁定;在非主線程中直接這樣創(chuàng)建Handler則會報錯,因為Android系統(tǒng)默認情況下非主線程中沒有開啟Looper,而Handler對象必須綁定Looper對象。
1.手動開啟Looper,然后將其綁定到Handler對象上
final Runnable runnable = new Runnable() {@Overridepublic void run() {//執(zhí)行耗時操作try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}} }; new Thread() {public void run() {Looper.prepare();new Handler().post(runnable);//在子線程中直接去new 一個handlerLooper.loop(); //這種情況下,Runnable對象是運行在子線程中的,可以進行聯(lián)網(wǎng)操作,但是不能更新UI} }.start();2.通過Looper.getMainLooper(),獲得主線程的Looper
final Runnable runnable = new Runnable() {@Overridepublic void run() {//執(zhí)行耗時操作try {Thread.sleep(2000);} catch (InterruptedException e) {e.printStackTrace();}} }; new Thread() {public void run() {new Handler(Looper.getMainLooper()).post(runnable);//這種情況下,Runnable對象是運行在主線程中的,不可以進行聯(lián)網(wǎng)操作,但是可以更新UI} }.start();xxx is not an enclosing class
- 一般出現(xiàn)在內(nèi)部類中,若要創(chuàng)建內(nèi)部類的實例,需要有外部類的實例才行,或者是將內(nèi)部類設(shè)置為靜態(tài)的,添加 static 關(guān)鍵字
there is no default constructor available in ...
子類中使用了無參構(gòu)造方法,而它的父類中至少有一個沒有無參的構(gòu)造方法。
- 如果一個類沒有構(gòu)造方法,會有一個默認的無參構(gòu)造方法。
如果顯示的定義了帶參構(gòu)造方法則默認的無參構(gòu)造方法就會失效。
一個類只要有父類,那么在它實例化的時候,一定是從頂級的父類開始創(chuàng)建
子類使用無參構(gòu)造函數(shù)創(chuàng)建子類對象時,會去先遞歸調(diào)用父類的無參構(gòu)造方法,這時候如果某個類的父類沒有無參構(gòu)造方法就會出錯
錯誤實例:
public class Parent{int aga;public Parent(int age){this.aga = age;}}public class Child extends Parent{public Child(){/** 默認調(diào)用父類的無參構(gòu)造方法 * super();*/}}如果子類使用帶參參構(gòu)造函數(shù)創(chuàng)建子類對象時,沒有使用super先調(diào)用父類的帶參構(gòu)造方法,這時默認會調(diào)用父類的無參構(gòu)造方法,如果父類沒有也會報錯
錯誤實例:
public class Parent{int aga;public Parent(int age){this.aga = age;}}public class Child extends Parent{public Child(int age){/** 默認調(diào)用父類的無參構(gòu)造方法 * super();*/}}上述也可以在子類調(diào)用父類的有參構(gòu)造函數(shù)
public class Child extends Parent{public Child(int age){super(age);}}JFinal
javax.servlet.ServletContext
BUG :The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required
Solution: 把tomcat/lib目錄中的jsp-api.jar和servlet-api.jar導(dǎo)入到項目的web/lib目錄下。
?
cast
BUG :Jfinal Db.findFirst java.lang.Long cannot be cast to java.lang.Integer
Solution:return Db.findFirst(sql).getLong("count").intValue();
?
?
錯誤: 編碼GBK的不可映射字符
BUG : eclipse導(dǎo)出javadoc時的錯誤: 編碼GBK的不可映射字符
Solution:-encoding UTF-8 -charset UTF-8
JavaScript
數(shù)組刪除元素
?
var arr = [1,2,3,4];arr.splice(1,1);/*** Array(3)* 0:1* 1:3* 2:4*/var arr = [1,2,3,4];delete arr[1];/*** Array(3)* 0:1* 1:undefined* 2:3* 3:4*/delete arr[1],arr[1]變?yōu)閡ndefined,數(shù)組的索引也保持不變
不要使用包裝對象來創(chuàng)建原始類型變量
在js中我們可以使用String()、Number()、Boolean()構(gòu)造函數(shù)來顯式的創(chuàng)建包裝對象
// String("test") , 一個字符串對象 // Number(5),一個數(shù)值對象 // Boolean(false),一個布爾對象// Don't do it!var x = new Boolean(false); if (x) {alert('hi'); // Shows 'hi'. }var x = Boolean(0); if (x) {alert('hi'); // This will never be alerted. } typeof Boolean(0) == 'boolean'; typeof new Boolean(0) == 'object';script文件異步加載
<script src="path/to/myModule.js" defer></script>
<script src="path/to/myModule.js" async></script>
<script>標簽打開defer或async屬性,腳本就會異步加載。渲染引擎遇到這一行命令,就會開始下載外部腳本,但不會等它下載和執(zhí)行,而是直接執(zhí)行后面的命令。
- defer與async的區(qū)別是:defer要等到整個頁面在內(nèi)存中正常渲染結(jié)束(DOM 結(jié)構(gòu)完全生成,以及其他腳本執(zhí)行完成),才會執(zhí)行;async一旦下載完,渲染引擎就會中斷渲染,執(zhí)行這個腳本以后,再繼續(xù)渲染。一句話,defer是“渲染完再執(zhí)行”,async是“下載完就執(zhí)行”。另外,如果有多個defer腳本,會按照它們在頁面出現(xiàn)的順序加載,而多個async腳本是不能保證加載順序的。
cookie
cookie只區(qū)分域名,不管端口
- cookie安全
1.1 httponly:設(shè)置了httponly屬性,無法通過腳本獲取到cookie信息
2.2 secure:設(shè)置了secure屬性,cookie只能通過https安全傳輸,并不會通過未加密的http連接發(fā)送
3.3 sameSite:目前只有chrome和firefox支持,用于定義cookie如果跨域發(fā)送
debug
debugger
可以在JavaScript手動添加斷點
debugger;DOM
右擊DOM元素,'Force Element State',展開子菜單可以看到幾種常見的偽類::active, :hover, :focus, and :visited??梢哉{(diào)試偽類。
右擊DOM元素,可以看到一個名為Break on的選項,展開有Subtree Modifications,Attributes Modifications以及Node Removal三個選項。(當JS嘗試改變DOM元素時,給元素添加的斷點便會觸發(fā)。)
a) Subtree Modifications,當添加,改變,刪除子元素時觸發(fā)
b) Attributes Modifications,當元素屬性被改變時觸發(fā)
c) Node Removal,當移除元素時觸發(fā)
Audits
Audits可以檢查頁面的性能方面存在的問題,并給出優(yōu)化意見
Jquery
Cannot read property 'msie' of undefined
原因是$.browser這個api從jQuery1.9開始就正式廢除,js代碼里只要用到$.browser就會報這個錯。
jQuery官方說明
1.1 可以替換成1.9之前的版本
2.2 使用插件jQuery Migrate,這個插件會恢復(fù)在更新版本中廢棄的API
3.3 在jQuery文件之后,$.browser的代碼之前 加載以下代碼
jQuery.browser={};(function(){jQuery.browser.msie=false; jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)./)){ jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();$.ajax
data封裝不加入JSON.stringify(data),會變成字符串拼接,'name=vinxent&age=21',有點和get方法相像。
若使用JSON.stringify(data),則會傳輸json對象'{name;'vinxent', age:21}'。
所以,在一般場景來說,get方法無需JSON.stringify,post方法需要。
Jquery動態(tài)綁定事件
//Jquery綁定事件$('.div').click(function(){});//Jquery動態(tài)綁定事件$('.div').on('click',function(){});<-- 當頁面動態(tài)刷新時,新加載的元素依然可以綁定事件 -->$(document).on('click','.div',function(){});Jquery on綁定hover事件
不能用on處理hover事件,因為Jquery的hover事件是一個封裝的事件,不是真正的事件。
所以使用mouseenter和mouseleave來代替鼠標懸浮和離開事件。
$(document).on('mouseenter', '.div', function() { });$(document).on('mouseleave', '.div', function() { });Jquery獲取時間并且格式化
Date.prototype.format = function(format) {/** eg:format="YYYY-MM-dd hh:mm:ss";*/var o = {"M+" :this.getMonth() + 1, // month"d+" :this.getDate(), // day"h+" :this.getHours(), // hour"m+" :this.getMinutes(), // minute"s+" :this.getSeconds(), // second"q+" :Math.floor((this.getMonth() + 3) / 3), // quarter"S" :this.getMilliseconds()// millisecond}if (/(y+)/.test(format)) {format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));}for ( var k in o) {if (new RegExp("(" + k + ")").test(format)) {format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]: ("00" + o[k]).substr(("" + o[k]).length));}}return format; }var startTime = new Date().format("yyyy-MM-dd 00:00:00"); var endTime = new Date().format("yyyy-MM-dd hh:mm:ss");滾動條滾動底部
scrollTop([val]) 獲取匹配元素相對滾動條頂部的偏移。
scrollLeft([val]) 獲取匹配元素相對滾動條左側(cè)的偏移。
scrollHeight 滾動條高度
Jquery size( )和length
size()是jQuery 提供的函數(shù),而 length是屬性。兩者的取值是一樣的。
頁面之間傳值
//頁面一location.href = "href2.html?id=3"; //頁面二var _url = document.URL;var _urlParam = _url.split('?')[1];var _value = _urlParam.split('=')[1];也可以使用jquery.params.js $.query.get("id");
### 靈活運用三目運算符
(_list.equipStatus ==1?"運行中":(_list.repairStatus ==2?"維修中":"待確認"))正確引用jQuery
2.借助第三方提供的CDN來引入jQuery,同時注意當使用第三方CDN出現(xiàn)問題時,要引入本地的jQuery文件。
3.如果在</body>前引入script文件的話,就不用寫document.ready了,因為這時執(zhí)行js代碼時DOM已經(jīng)加載完畢了。
優(yōu)化jQuery選擇器
<div id="nav" class="nav"> <a class="home" href="http://www.jquery001.com">jQuery學(xué)習(xí)網(wǎng)</a> <a class="articles" href="http://www.jquery001.com/articles/">jQuery教程</a> </div>如果我們選擇class為home的a元素時,可以使用下邊代碼:
$('.home'); //1
$('#nav a.home'); //2
$('#nav').find('a.home'); //3
2.方法2,為要查找的元素添加了上下文,在這里變?yōu)椴檎襥d為nav的子元素,查找性能得到了很大提升。
3.方法3,使用了find方法,它的速度更快,所以方法三最好。
關(guān)于jQuery選擇器的性能優(yōu)先級,ID選擇器快于元素選擇器,元素選擇器快于class選擇器。因為ID選擇器和元素選擇器是原生的JavaScript操作,而類選擇器不是。
緩存jQuery對象
緩存jQuery對象可以減少不必要的DOM查找,關(guān)于這點大家可以參考下緩存jQuery對象來提高性能。
// 糟糕 h = $('#element').height(); $('#element').css('height',h-20);// 建議 $element = $('#element'); h = $element.height(); $element.css('height',h-20);使用子查詢緩存的父元素
正如前面所提到的,DOM遍歷是一項昂貴的操作。典型做法是緩存父元素并在選擇子元素時重用這些緩存元素。
// 糟糕 var$container = $('#container'),$containerLi = $('#container li'),$containerLiSpan = $('#container li span'); // 建議 (高效) var$container = $('#container '),$containerLi = $container.find('li'),$containerLiSpan= $containerLi.find('span');精簡jQuery代碼
一般來說,最好盡可能合并函數(shù)。
// 糟糕 $first.click(function(){$first.css('border','1px solid red');$first.css('color','blue'); }); // 建議 $first.on('click',function(){$first.css({'border':'1px solid red','color':'blue'}); });減少DOM操作
最小化DOM更新
重布局和重繪是WEB頁面中最常見的也是最昂貴的兩種操作。
當改變樣式,而不改變頁面幾何布局時,將會發(fā)生重繪。隱藏一個元素或者改變一個元素的背景色時都將導(dǎo)致一次重繪。
當對頁面結(jié)構(gòu)進行更新時,將導(dǎo)致頁面重布局。
prop和attr方法
對于元素自身的固有屬性 使用 prop 對于自定義的屬性使用attr方法
例:獲取選中的checkbox的value值
$("input[type=checkbox]").each(function() {if(true == $(this).prop("checked")) {alert($(this).attr("value"));}});each遍歷
用each實現(xiàn)全選或是取消全選。
$("#selectAll").click(function() {if($("#selectAll").prop("checked")) {$("#selectAll input[type=checkbox]").each(function() {$(this).prop("checked", "true");});} else {$("#selectAll input[type=checkbox]").each(function() {$(this).removeAttr("checked");});}});layer.js
uploadify.js error placeholder element
這是因為input 元素必須有id,并且用id初始化uploadify函數(shù)。否則就報錯。
chart.js
Uncaught TypeError: Cannot read property 'length' of null
這個問題是因為js代碼執(zhí)行的時候canvas還沒有被創(chuàng)建。可以將初始化圖表代碼片段放到window.onload后面
window.onload = function() {var ctx = document.getElementById("myChart");var lineChart = new Chart(ctx, {type: 'line',data: {labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],datasets: [{label: "2015",data: [10, 8, 6, 5, 12, 8, 16, 17, 6, 7, 6, 10]}]}}) }The problem is that when your code executes, the canvas has not been created yet. You should wrap your code inside a function and assign that function to window.onload event. You can see the sample code below.
Cannot read property 'transition' of null
Try to call mychart.update() after setting the new data... that solved the problem for me.
Browser
Slow network is detected. Fallback font will be used while loading
新版本的Chrome在網(wǎng)絡(luò)環(huán)境較差的時候會在控制臺輸出Slow network is detected. Fallback font will be used while loading,但有時會對調(diào)試造成不便,可以在chrome配置中禁用該項:?
地址欄輸入chrome://flags/#enable-webfonts-intervention-v2,并設(shè)置為Disabled;重啟Chrome。
AngularJS
$sce
$sce is included by default starting with angular 1.2- so you don't need sanitize anymore in order to get $sce. So, with 1.2, you can pass $sce in as any other service. But make sure your angular is version 1.2 (in case you checked the sanitize version vs core).
獲取body元素
// $document 服務(wù)$document[0].bodyangular.element(document).find('body')防抖動輸入
<body ng-controller="myCtrl"><div ng-app="App" ng-controller="Ctrl" class="app"><button ng-click="inc()">Add</button><span>{{ val }}</span></div><script>angular.module("App", []).controller("Ctrl", ['$scope', '$debounce', function($scope, $debounce) {$scope.shouldBeFocus = true;$scope.val = 0;$scope.inc = function() {$debounce(increase, 300);};var increase = function() {$scope.val++;}}]).factory('$debounce', ['$rootScope', '$browser', '$q', '$exceptionHandler',function($rootScope, $browser, $q, $exceptionHandler) {var deferreds = {},methods = {},uuid = 0;function debounce(fn, delay, invokeApply) {var deferred = $q.defer(),promise = deferred.promise,skipApply = (angular.isDefined(invokeApply) && !invokeApply),timeoutId, cleanup,methodId, bouncing = false;// check we dont have this method already registeredangular.forEach(methods, function(value, key) {if(angular.equals(methods[key].fn, fn)) {bouncing = true;methodId = key;}});// not bouncing, then register new instanceif(!bouncing) {methodId = uuid++;methods[methodId] = {fn: fn};} else {// clear the old timeoutdeferreds[methods[methodId].timeoutId].reject('bounced');$browser.defer.cancel(methods[methodId].timeoutId);}var debounced = function() {// actually executing? clean method bankdelete methods[methodId];try {deferred.resolve(fn());} catch(e) {deferred.reject(e);$exceptionHandler(e);}if(!skipApply) $rootScope.$apply();};timeoutId = $browser.defer(debounced, delay);// track id with methodmethods[methodId].timeoutId = timeoutId;cleanup = function(reason) {delete deferreds[promise.$$timeoutId];};promise.$$timeoutId = timeoutId;deferreds[timeoutId] = deferred;promise.then(cleanup, cleanup);return promise;}// similar to angular's $timeout canceldebounce.cancel = function(promise) {if(promise && promise.$$timeoutId in deferreds) {deferreds[promise.$$timeoutId].reject('canceled');return $browser.defer.cancel(promise.$$timeoutId);}return false;};return debounce;}]);;</script></body>this in AngularJS
angular.module("App", []).controller("Ctrl", function($scope) {// this controllerconsole.log("controller",this);$scope.foo = function() {// this scopeconsole.log("foo",this);};var foo2 = function() {// this windowsconsole.log("foo2",this);}$scope.foo();foo2();});angular.copy() angular.extend()
angular.copy(source, [destination]); // source: copy的對象. 可以使任意類型, 包括null和undefined. destination:接收的對象 返回復(fù)制或更新后的對象
如果省略了destination,一個新的對象或數(shù)組將會被創(chuàng)建出來;
如果提供了destination,則source對象中的所有元素和屬性都會被復(fù)制到destination中;
如果source不是對象或數(shù)組(例如是null或undefined), 則返回source;
如果source和destination類型不一致,則會拋出異常。
angular.extend(destination, source);
復(fù)制src對象中的屬性到dst對象中. 支持多個src對象. 如果你不想改變一個對象,你可以把dst設(shè)為空對象{}: var object = angular.extend({}, object1, object2).
注意: angular.extend不支持遞歸復(fù)制.
Git
push 需要輸入用戶名和密碼
換成ssh方式
git remote -v // origin https://github.com/xxxxxx/xxxx.git (fetch) // origin https://github.com/xxxxxx/xxxx.git (push)git remote rm origingit remote add origin git@github.com:xxxxx/xxxx.gitgit push origingit默認用notepad++ 打開
git config --global core.editor "'D:\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin '$*'"npm
npm WARN saveError ENOENT: no such file or directory ... package.json
npm init -f
生成一個package.json
React
render(, document.body);
warning.js:36 Warning: render(): Rendering components directly into document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try rendering into a container element created for your app.
ReactDOM.render(<Greeter />, document.getElementById('react_container'));轉(zhuǎn)載于:https://www.cnblogs.com/chenjy1225/p/9661237.html
總結(jié)
以上是生活随笔為你收集整理的program collections的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 焦旭超 201771010109《面向对
- 下一篇: 新华社:华尔街专家警告2019年美股或面