-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:joey998/blog
- Loading branch information
Showing
3 changed files
with
2,174 additions
and
807 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function testLog(a,b,cs){console.log(a, b, c);} | ||
|
||
function alert(a) { | ||
alert(a); | ||
} | ||
|
||
|
||
// 以下每一种都能被匹配到 | ||
const a1 = 123; | ||
const a2 = "b"; | ||
const a3 = () => 1; | ||
|
||
const dict = { | ||
a: 1, | ||
b: 2, | ||
c: 'f', | ||
}; | ||
|
||
class Toggle extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { isToggleOn: true }; | ||
|
||
// This binding is necessary to make `this` work in the callback | ||
this.handleClick = this.handleClick.bind(this); | ||
} | ||
|
||
handleClick() { | ||
this.setState((prevState) => ({ | ||
isToggleOn: !prevState.isToggleOn, | ||
})); | ||
} | ||
|
||
render() { | ||
return ( | ||
<button onClick={this.handleClick}> | ||
{this.state.isToggleOn ? 'ON' : 'OFF'} | ||
</button> | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class Toggle extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { isToggleOn: true }; | ||
// This binding is necessary to make `this` work in the callback | ||
this.handleClick = this.handleClick.bind(this);; | ||
this.handleClick = this.handleClick.bind(this) | ||
} | ||
|
||
handleClick() { | ||
this.setState((prevState) => ({ | ||
isToggleOn: !prevState.isToggleOn, | ||
})); | ||
} | ||
|
||
render() { | ||
return ( | ||
<button onClick={this.handleClick}> | ||
{this.state.isToggleOn ? 'ON' : 'OFF'} | ||
</button> | ||
); | ||
} | ||
} |
Oops, something went wrong.