import React from 'react';
import {Button} from "antd";
const Demo = () => {
let lastVal =null // 记录下上次的值
const getValue = (val) => {
const thisValue = lastVal ==val ?'' :val // 先把上次的值传给这次
lastVal =thisValue // 再把这次的值保存起来
console.log(thisValue,44444444)
}
return (
<div>
<Button onClick={()=>getValue('孙继稳')}>点击反转 </Button>
</div>
);
};
export default Demo;
反转按钮点击两次第一次获取值第二次为空
于 2022-05-23 21:05:28 首次发布