vue i18 data中定义变量,更新语言不刷新问题

第一种

1 watch: {
2 '$i18n.locale'(newValue) {
3   console.log('aaaaaa', newValue)
4   this.init(); // 重新给 data的变量赋值
5 }
6 },

 

第二种

js 中
 data中:
  val: 'language.listen.home.sch_opt_auth_val',  // 直接定义 语言的key.   。通过$t() 方法自动更新实现。
html中

    $t(val)

posted @ 2022-05-06 10:55  随心一击  阅读(620)  评论(0)    收藏  举报