[React/Vue] Event triggering

Preface:
In many cases, it is necessary to determine whether an event is triggered based on the judgment condition. The event here refers to the click (click) event, change (change) event, etc. used in the React or Vue project. Here is a relatively simple implementation method: the code is as follows (taking React as an example)
:

//比如需要满足status==='0'才能触发点击事件。使用&&就可以实现
<View onClick={
    
    () => {
    
    status === '0' && handleClick()}}></View>

Guess you like

Origin blog.csdn.net/weixin_42342065/article/details/126530166