The front-end solves the bug of being unable to add click events after the input box is disabled. It is simple and easy to understand. Come and watch.

In development, we often encounter the problem of needing to disable the input box, but the click event cannot be added after it is disabled. This problem may bother you, but don’t worry, this article will introduce you to a method to solve this problem.

The solution is simple, just add style="pointer-events:none" to the parent node view of the input box . The specific implementation is as follows:

<view class="nameBox" @click="selectPeo">
  <input type="text" disabled style="pointer-events:none" v-model="gengzu" placeholder="请选择线索填报人" placeholder-class="fontColor" />
</view>

The principle of this is to overlay the view's click event on the input box, so that the input box no longer responds to click events, but the view can still respond to click events, thus achieving the desired effect.

It should be noted that this method is only applicable when the input box is disabled. If the input box is not disabled, using this method may cause the input box to be unable to respond to input events.

Finally, I hope this article can help you solve this problem. If you have any other questions or suggestions, please leave a message .

Thank you for reading, and I look forward to your continued support, Crab! .

AuthorEmo_TT  

Guess you like

Origin blog.csdn.net/qq_48652579/article/details/130107401