0
0

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 3 years have passed since last update.

vue-i18nをVue.jsのJavascriptで使う方法

Posted at

vue-i18nで定義したメッセージをVue.jsのJavascriptで使う方法についてです。

テンプレートで使う方法については検索すればたくさん出てきます。
Javascriptから使う方法がなかなか見つけられなかったので、投稿します。

環境

    "vue": "^2.6.11",
    "vue-i18n": "^8.15.4",

langファイル

利用するlangファイルは以下の通りです。

export default {
    // 共通
    common: {
        errorLabel: 'エラー',
        toastCloseButtonText: '閉じる',
    },
}

Javascriptで使う方法

this.$i18n.t('common.toastCloseButtonText')
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?