From 5d783709c67092fe0c6a6d904020fd1607d76b22 Mon Sep 17 00:00:00 2001 From: ruilinsun Date: Tue, 24 Sep 2024 17:01:03 -0700 Subject: [PATCH] add react syn --- common_usage_case/react.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 common_usage_case/react.js diff --git a/common_usage_case/react.js b/common_usage_case/react.js new file mode 100644 index 0000000..bd705e2 --- /dev/null +++ b/common_usage_case/react.js @@ -0,0 +1,36 @@ +function getArticleTem() { + //简单传递 + const clickHandler = () => { + console.log('') + } + //事件参数e,e可以被console接收 + const clickHandler = (e) => { + console.log('',e) + } + return( +
+ + { + articleType === 1 ? Loading... : + articleType === 2 ? Error occurred : + articleType === 3 ? Operation successful : + Unknown status + } +
+ ) + + //形参传递实参 : 利用箭头函数的形式引用 + const clickHandler = (name) => { + console.log('',name) + } + return() + + + //同时传递事件对象和自定义参数 + const clickHandler = (name , e) => { + console.log('',name , e) + } + return() + + } + \ No newline at end of file