js 的幾個坑

2021-08-31 03:36:54 字數 559 閱讀 6491

about_post_ids=about_post_ids.split(",");
就算是乙個空值,也會被分割成乙個陣列,可以用alert(arr.lenght),測試;

如果是   ,1,2,3 或者  1,2,3,  或  , 都或生產乙個空值。

空值的清除: 

about_post_ids=$.grep(about_post_ids, function(n) )

about_post_ids = about_post_ids.filter(s => $.trim(s).length > 0);

查詢陣列中是否存在某值:

if(about_post_ids.indexof('liangfang')===-1)
陣列的迴圈:

about_post_ids.foreach(function (ele,index,array) {  //ele 是當前陣列的值,index 是當前下標,索引值,key 值,array 原來的數值

console.log(ele+index);

除第乙個引數,後面的可以選填

Sqlite的幾個坑

如果使用 cursoradapter進行適配時,切記開啟的資料庫的表名的主鍵名稱前要加 如果工程中有兩個activity,如果要啟動其中乙個activity,需要在manifest.xml檔案中將intent filter加到該activity下面,如圖要啟動cursoradapteractivit...

windows nginx的幾個坑

今天在windows下弄nginx遇到幾個坑。首先是windows下的安裝。應該參考官網 nginx error openevent global ngx reload 5744 failed 或 nginx error openevent global ngx quit 5744 failed 或...

MediaRecorder的幾個常見坑

private void initrecord throws ioexception catch illegalstateexception e catch runtimeexception e catch exception e 原因 設定的寬高數值必須要和攝像頭支援的數值相匹配,否則報錯 解決方...