2
2

More than 3 years have passed since last update.

【Vue.js】IMEで変換中の文字列を取得する

Last updated at Posted at 2021-01-03

v-modelだとIME変換中の文字は取得できない。

出来ない例
<input type="text" v-model="message">
// これだと変換中なにも取得できない...

ドキュメント見てたらそれらしきものを発見

IMEを必要とする言語 (中国語、日本語、韓国語など) においては、IME による入力中にv-modelが更新を行わないことに気づくでしょう。このような入力に対しても同様に扱いたい場合は、代わりにinput イベントを使用してください。
フォーム入力バインディング/基本的な使い方

この書き方でできるらしい

app.js
<input
  v-bind:value="message"
  v-on:input="message = $event.target.value"
>

コンポーネントの基本/コンポーネントで v-model を使う

See the Pen 【Vue.js】フォーム入力バインディングでIMEに対応 by 匠君 (@takumikunn15) on CodePen.

2
2
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
2
2