【问题标题】:typeScript+ vue+property decorator : prop default value typetypeScript+ vue+property 装饰器:prop 默认值类型
【发布时间】:2022-01-18 11:29:05
【问题描述】:

你好,

我有一个这样的道具,

当我想使用 i18n

翻译文本时遇到输入错误
  @Prop({
default: function() {
  return [
    {
 >     text: this.$t('wawi_id'),
      align: 'start',
      sortable: false,
      value: 'id'
    },
    { text: 'Name', value: 'name' },
  
  ]
}
})

这是我从 typescript

得到的错误
 Property '$t' does not exist on type 'PropOptions<any> | Constructor | Constructor[]'.
  Property '$t' does not exist on type 'PropOptions<any>'.Vetur(2339)

如何解决这个问题??

【问题讨论】:

    标签: typescript vue.js nuxt.js vue-i18n


    【解决方案1】:

    您没有正确使用this 关键字。试试这个:

    text: this.$i18n.t("wawi_id"),
    

    【讨论】:

      猜你喜欢
      • 2020-06-29
      • 2021-04-24
      • 2018-11-19
      • 2019-07-23
      • 1970-01-01
      • 2022-08-15
      • 1970-01-01
      • 2020-09-03
      • 2018-07-08
      相关资源
      最近更新 更多