Vue uses the input box of elementUi as a file selection box, using skills

We know that input can only have events such as input, input, change, and mouse entry, and there is no click event, but if there is an input box that allows users to choose the download path, how to modify it?

In fact, at the beginning, I wanted to use the element to get the focus event, and then by processing the focus event, open the dialog box, and then select the file, but there is a problem here, that is, after the file is selected, the element still gets the focus, and then it will continue to open the dialog box, an infinite loop... Even if you use e. 

Then I was thinking, since this input box cannot use the click event, how about wrapping it with an element, binding the click event to the outer element, and then realizing it through event bubbling? Well, after my unremitting efforts, this plan is good

Then the path is successfully obtained: and there is no infinite loop problem

Guess you like

Origin blog.csdn.net/weixin_44786530/article/details/131896308
Recommended