Is it bad practice to write inline event handlers

前端 未结 3 1572
南方客
南方客 2021-02-04 23:17

Is it bad practice to write inline event handlers ?

For me, I prefer use it when I want to use a local variable in the event handler like the following:

I prefer

3条回答
  •  情歌与酒
    2021-02-04 23:46

    You put the two samples together. It is clear that the second option (which you don't prefer) is the most readable.

    Code readability and maintainability are very important. Keep things simple, as easy as possible to understand. Lambda expressions are generally considered harder to understand by majority of people. Even if they are a second nature for you for others might not.

提交回复
热议问题