vue组件中的翻译

时间:2018-06-22 07:18:52

标签: javascript laravel vue.js

if (self.form.pickupTime == '') {
  self.formError.pickupTime = 'Ready for pickup time is required.';
  status = false;
  return status;
} else {
  self.formError.pickupTime = '';
}

我需要翻译“需要准备上车时间”。这是VueLaravel文件。尝试过{{ $t('vue.readytime') }},但弹出错误。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您可以在某些.blade.php文件中定义lang vars

var lang = {
  pickupTime: "{{ t('vue.readytime') }}",
};

并在vue组件中使用lang var

self.formError.pickupTime = lang.pickupTime;