Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions common_usage_case/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function getArticleTem() {
//简单传递
const clickHandler = () => {
console.log('')
}
//事件参数e,e可以被console接收
const clickHandler = (e) => {
console.log('',e)
}
return(
<div className = 'getArticleTem'>
<button onClick = {clickHandler}></button>
{
articleType === 1 ? <span>Loading...</span> :
articleType === 2 ? <span>Error occurred</span> :
articleType === 3 ? <span>Operation successful</span> :
<span>Unknown status</span>
}
</div>
)

//形参传递实参 : 利用箭头函数的形式引用
const clickHandler = (name) => {
console.log('',name)
}
return(<button onClick = {() => clickHandler('jack')}> clickme </button>)


//同时传递事件对象和自定义参数
const clickHandler = (name , e) => {
console.log('',name , e)
}
return(<button onClick = {(e) => clickHandler('jack' ,e)}> clickme </button>)

}