【问题标题】:VueI18n passing string in a custom table VueJSVueI18n 在自定义表 VueJS 中传递字符串
【发布时间】:2018-11-18 11:26:22
【问题描述】:

我正在使用 vue-good-table 来渲染表格。

 <vue-good-table
    :columns="columns"
    :rows="items"
    :paginate="true"
    :lineNumbers="true">
  </vue-good-table>

columns: [
          {
            label: 'Date',
            field: 'date',
            type: 'String',
            filterable: true,
            placeholder: 'Date'
          }
]

无论如何我可以在标签参数中使用例如 {{ $t("column.date") }} 。直到现在它只在传递字符串时才有效?

添加更多代码:

ma​​in.js 常量 i18n = 新的 VueI18n({ locale: 'bg', // 设置语言环境 fallbackLocale: 'bg', messages // 设置区域信息 });

Vue.prototype.$locale = {
  change (lang) {
    i18n.locale = lang
  },
  current () {
    return i18n.locale
  }
}

【问题讨论】:

    标签: vue.js internationalization


    【解决方案1】:

    columns: [
              {
                label: this.$t("column.date"),
                field: 'date',
                type: 'String',
                filterable: true,
                placeholder: 'Date'
              }
    ]

    【讨论】:

    • 输出是“column.date”,它不是那样工作的。它没有显示真正的信息
    • 哦,是的,谢谢我打错字了,但是语言之间的切换不适用于这个组件。当我点击英语/保加利亚语按钮时,它会停留在保加利亚语(默认选项)上。
    • 事实上,它确实改变了语言。然而,除了表格之外,它在任何地方都会改变语言。有什么解决办法吗?
    猜你喜欢
    • 1970-01-01
    • 2012-05-28
    • 2022-09-30
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-27
    相关资源
    最近更新 更多