1、部分引入 lodash
import debounce from 'lodash/debounce';
复制代码
2、绑定 this 致使 function 里使用 this 正常调用
ps: 不正确绑定 this 会导致后面 cannot find something of undefined 的报错
绑定 this 引用了这篇 文章
<Button
onClick={debounce(this.changeMapType.bind(this), 200)}>
{this.state.chartType === 1 ? '桑基图' : '树图'}
</Button>
复制代码
注意
debounce 需要在 onClick 里直接添加 箭头函数会导致实现
复制代码