type A {
a: string,
}
type B {
b: number
}
const data: A | B = { a: 'Hello' }
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
document.querySelectorAll('.title-group.-gantt').forEach(item => item.click()) |
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
// https://www.typescriptlang.org/play?#code/PTAEjztRRNMTwzDu3RaOUKe6gdeQFAGMD2A7AzgF1AAUBTAJwFsBLXXKnXUAXlAG9VRQySBDAEwBcoAOTd+wgDQdQAdzJV8JIcLkKSk6SQAeJdAFdFy7boPrUAX1A9GWPPgDcqfAE8ADiWLlqtetmagXd0wAM09KGjoGAG0AaxJnEIC3EkTScJ8GAF17UBARMT5hUAAfEVVFItLhY30KoA | |
// typescript playgroud 工作,实际项目中不工作 | |
const permissions = ['read', 'write', 'execute'] as const; | |
type Permission = typeof permissions[number]; // 'read' | 'write' | 'execute' | |
// typescript playgroud 不工作,实际项目中工作 | |
const Permissions = { | |
read: 'read', | |
write: 'write', |
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
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }) | |
// 'a[0]=b&a[1]=c' | |
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }) | |
// 'a[]=b&a[]=c' | |
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) | |
// 'a=b&a=c' | |
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' }) | |
// 'a=b,c' |
- 入门教程:认识 React https://reactjs.org/tutorial/tutorial.html
- 重点理解 hooks API https://reactjs.org/docs/hooks-intro.html
- 学习一种 Router https://reactrouter.com/
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
export const isDark = () => window.matchMedia('(prefers-color-scheme: dark)').matches; |
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
function isLeapYear(year: number) { | |
return new Date(year, 1, 29).getDate() === 29 | |
} | |
export default isLeapYear |
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
{ | |
"scripts": { | |
"//start": "Start the app", | |
"start": "react-scripts start", | |
"//test": "Run unit tests", | |
"test": "react-scripts test" | |
} | |
} |
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
因为 Object props 在使用 defaultProps 容易出现错误。 | |
因为 defaultProps 是替换,而不是合成。 |
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
解决方法 | |
1. 先删除文件,再加进去 | |
``` | |
git rm <filename> | |
git add <filename> | |
git add commit -m “rename file" |