search

Home  >  Q&A  >  body text

Using $t in alert() for Vue’s i18n translation

<p>I'm using Vue 2.6.14 and vue-i18n 8.25 I can't figure out how to put the i18n translation in alert()...</p> <pre class="brush:php;toolbar:false;">async ChangePassword() { await axios.post('/api/reset-password', this.form).then((response) => { alert( {{ $t('Password has been changed') }} ); })}</pre> <p>This doesn't seem to work. </p>
P粉757556355P粉757556355462 days ago449

reply all(1)I'll reply

  • P粉403804844

    P粉4038048442023-08-27 10:30:25

    Try using this

    alert( this.$t('密码已更改') );

    reply
    0
  • Cancelreply