W
W
wipe00092021-06-06 20:41:29
Vue.js
wipe0009, 2021-06-06 20:41:29

How to put alert using i18n Vue 3 Cli?

Hello, please tell me how can I use alert( t("hello") );
using en.json / ru.json
For example
import { useI18n } from "vue-i18n";

setup() {
    const { t } = useI18n({
      inheritLocale: true,
      useScope: "local",
    });

    return { t };
  },

mounted(){alert (t("hello"))}
does not work
Uncaught TypeError: vue_i18n__WEBPACK_IMPORTED_MODULE_2__.useI18n.t is not a function

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-06-06
@wipe0009

Most likely your t is not a function. Maybe it's a string, or a Ref to a string, or a Ref to a function. Try alert(t.value("hello")). Well, or just print your t to the console and see what it is.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question