1
jQuery $( "#element")。focus();関数は、最初にv-if divで機能しません。Vue.js jQuery.focusは機能しません。
こんにちは、私はVue jsで次の問題があります。私はv-ifで読み込み時に隠されているdivを持っています。 v-if条件が真の場合、divは表示されますが、そのdiv内の入力フィールドはフォーカスしないようにします。 $( "#element")。focus();これは、divが表示された後初めて初めて発生します.focus()works
ex。私は$( "#1 UPC")を呼び出す> 0 this.boxes.lenghtボックスたら
<div class="row" v-show="boxes.length > 0">
<div class="col-md-6">
<input v-model="upc" type="text" class="form-control" name="upc" placeholder="Scan UPC here" id="upc" @keyup.13="scan">
</div>
</div>
Htmlの
方法 にaddBox: function (event)
{
this.boxes.push({id: 1, name: 'Name', weight: 10 }); // Default is empty array. Comes true when i call this function and the div with #upc input becomes active and displayed
$("#upc").focus(); // When the first time boxes becomes true $("#upc").focus(); does not work. Once is displayed it works after.
}
を、この機能を持っている()を集中します。入力フィールドをフォーカスします。
Ty sir、nextTickは魅力的に機能します。 –