0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vue.jsで実装されたformの値をフロント側からJavascriptで変更する

Posted at

問題

WebViewアプリなどでやむを得ずinputフォームにフロント側から値を入れたい場合に、通常であればvalueに突っ込むだけで良かったのですが、Vue.jsだとそれだけでは裏側の値にまで反映されないみたいです。

解決法

inputイベントを更新のトリガにしているようなので、valueの変更後に呼んであげるだけでした。

document.getElementById('accountId').value = 'アカウントID';
document.getElementById('accountId').dispatchEvent(new Event('input'));
// 送信ボタンなど
document.getElementById('button').click();
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?