This commit is contained in:
2022-05-03 19:49:45 +08:00
parent ef97468194
commit a0a73cd2f1
6 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
<!--
* @Author: chenxuan
* @Date: 2022-01-08 20:04:29
* @LastEditTime: 2022-01-08 20:05:31
* @LastEditTime: 2022-05-02 09:35:50
* @LastEditors: chenxuan
-->
<!DOCTYPE html>
@@ -23,11 +23,11 @@
this.state={
ishot:true
}
// 解决this指向问题
this.demo=this.demo.bind(this)
}
render(){
const {ishot}=this.state;
// 解决this指向问题
return <h1 onClick={this.demo}>今天天气很{ishot ? '炎热' : '凉爽'}</h1>
}
demo(){
+1 -1
View File
@@ -1,7 +1,7 @@
<!--
* @Author: chenxuan
* @Date: 2022-01-01 14:00:24
* @LastEditTime: 2022-01-01 22:27:36
* @LastEditTime: 2022-05-02 10:10:46
* @LastEditors: chenxuan
-->
<!DOCTYPE html>
+3 -2
View File
@@ -1,7 +1,7 @@
<!--
* @Author: chenxuan
* @Date: 2022-01-02 22:09:19
* @LastEditTime: 2022-03-20 14:35:58
* @LastEditTime: 2022-05-02 12:18:45
* @LastEditors: chenxuan
-->
<!DOCTYPE html>
@@ -23,11 +23,12 @@
// 这种写法,更新时不会调用
haha=(c)=>{
this.hehe=c;
console.log("xx")
}
change=()=>{
const {ishot}=this.state;
this.setState({ishot:!ishot});
console.log(this.hehe.value)
}
render(){
const {ishot}=this.state;