The input tag becomes compatible with the search box in the mobile terminal

The basic writing method of the input tag is:

<input type="text">

  In the mobile terminal, we will find that the enter key is just an ordinary enter key logo. In order to turn the Enter key into a search flag, we can add attributes
to the input tag , namely:type="search"

<input type="search" />

  However, in the ios system, the enter key is still an ordinary enter key mark. In order to make the ios system also become a search mark, we need to wrap the input tag with a form, namely:

<form action>
    <input type="search" />
</form>

  But when we only want to make a search box, it will trigger the submission of the form, so we can't effectively combine the Enter key event. So the default behavior of the form must be prevented, we can do this:

<form action="JavaScript:return true;">
    <input type="search" @keyup.enter.native="findDrug" />
</form>

  In this way, we can use the input tag as a search box on the mobile terminal.

Guess you like

Origin blog.csdn.net/weixin_50096821/article/details/123606900