我有一個表單,我想在其中將焦點設定在輸入欄位上。這是表單的html:
<form method="GET" name="searchFormArticles" novalidate="" data-search-form="articles" data-search-form-articles="" action="/rechtstipps" id="searchFormArticles" data-read-only="1">
<input type="text" name="what" id="searchArticlesWhat" placeholder="Thema / Autor / Titel" class="form-control anw-form-control border-left-0 anw-md-rounded-right-none anw-md-border-right-0 shadow-none form-control" value="" autocomplete="off">
<button name="searchArticles" type="submit" class="btn btn-block btn-primary mt-3 mt-md-0 shadow-none text-nowrap py-md-0 px-9 anw-md-rounded-left-none">
<i class="far fa-search d-none d-md-inline-block text-primary" aria-hidden="true"></i>
<span>Suchen</span>
</button>
輸入欄位也有一個 name=what 屬性和一個 id 屬性,我怎樣才能在 vue 中捕獲這個輸入元素
uj5u.com熱心網友回復:
您可以在第一個輸入欄位中提供 autofocus 屬性。
<input type="text" name="what" id="searchArticlesWhat" placeholder="Thema / Autor / Titel" class="form-control anw-form-control border-left-0 anw-md-rounded-right-none anw-md-border-right-0 shadow-none form-control" value="" autocomplete="off" autofocus>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/372762.html
標籤:javascript Vue.js
下一篇:Vue:將id移交給其他組件
