This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"editor.suggestSelection": "first", | |
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", | |
// Prettier 套件格式啟動 | |
"editor.defaultFormatter": "esbenp.prettier-vscode", | |
// Tab 間隔 | |
"editor.tabSize": 2, | |
// Sass 套件 打開 | |
"sass.lint.enable": true, | |
// 字體大小 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 這是一個 DataTable 的表格,最左邊欄位會有 checkboxes,可以讓 User 複選。 | |
export const tableSelectRow = (selectedEDILogIdList) => ({ | |
mode: 'checkbox', | |
selectionHeaderRenderer: renderSelectionHeader, | |
selectionRenderer: renderSelection, | |
style: { backgroundColor: '#c8e6c9' }, | |
onSelect: (row, isSelect) => { | |
if (isSelect) { | |
// 這裡使用到 array 的 push 語法,意思是點選到該 row 時,把該 row 的 id,放到該陣列末端。 | |
selectedEDILogIdList.current.push(row.id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 撇開 React 相關的語法,在這裡很常使用 array.length 陣列長度,來判斷某些事情及達到什麼事情。 | |
const handleReprocess = useCallback(() => { | |
// 是指該陣列長度不為 0 的話,就跳出 SweetAlert confirm 的視窗。 | |
if (selectedEDILogIdList.current.length !== 0) { | |
SweetAlert.confirm({ | |
text: 'You really want to Reprocess it !?', | |
timer: 3000, | |
callback: () => { | |
return dispatch(reprocessEDILogIds(selectedEDILogIdList.current)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var number = [4, 9, 14, 19] | |
var result = number.filter((value, index, array) => { | |
return (value % 2 === 1) // % 為餘數運算子 | |
}) | |
console.log(result) // 會得到 [9, 19] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var number = [2, 3, 4, 5] | |
var result = number.map((value, index, array) => { | |
return (value + value) | |
}) | |
console.log(result) // 會得到 [4, 6, 8, 10] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ary1 = ['TRCK', 'MOP', 'CFS', 'WMS'] | |
var ary2 = ['APPLE', 'MGF', 'AMAT', 'ACER', 'WURTH'] | |
console.log(ary1.length) // 會得到 4 | |
console.log(ary2.length) // 會得到 5 | |
console.log(Array.isArray(ary1)) // 會得到 true | |
console.log(ary1.concat(ary2)) // 會得到 ['TRCK', 'MOP', 'CFS', 'WMS', 'APPLE', 'MGF', 'AMAT', 'ACER', 'WURTH'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = ['MOP', 'CFS', 'WMS', ['AMAT', 'WURTH', 'MGF'], 'TMS'] | |
console.log(data[3][0]) // 會取得 AMAT (會取得第 3 個元素的第 1 個元素) | |
console.log(data[3][2]) // 會取得 MGF (會取得第 3 個元素的第 3 個元素) | |
console.log(data[3][3]) // 會取得 undefined (因為第 3 個元素的第 4 個元素不存在) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = ['MOP', 'CFS', 'WMS', 'TRCK', 'TMS'] | |
console.log(data[0]) // 會取得 MOP (取得索引值為 0,也就是第 1 個元素) | |
console.log(data[2]) // 會取得 WMS (取得索引值為 2,也就是第 3 個元素) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 基本 switch 指令介紹 | |
switch (條件式) { | |
case 1: | |
符合 「條件式 = 值 1」時要執行的指令 (區塊) | |
case 2: | |
符合 「條件式 = 值 2」時要執行的指令 (區塊) | |
... | |
default: | |
以上全部條件式都不符合時執行此指令 (區塊) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 基本 if else 指令介紹 | |
if (條件式 1) { | |
條件式為 1 為 true 時執行此指令區塊 | |
} else if (條件式 2) { | |
條件式為 2 為 false 時執行此指令區塊 | |
} | |
... | |
} else { | |
以上全部條件都為 false 時執行此指令區塊 | |
} |