vue.js - 从 vuejs 组件访问 i18n 值
问题描述
我使用 i18n 为应用程序提供多语言支持,我希望我为 highcharts 提供的图表具有相同的行为。
<i18n>
{
"fr": {
"test": "en fançais"
},
"en": {
"test": "in english"
}
}
</i18n>
<template>
<highcharts :options="options"></highcharts>
</template>
<script>
import '@/plugins/highcharts.js'
export default {
data() {
return {
options: {
chart: {
type: 'bar'
},
series: [{
name: $t('test'),
data: [1.0, 0.3, 0],
color: '#beab9d'
}],
xAxis: {
categories: ["1", "2", "3"]
}
}
}
}
}
</script>
但是在构建应用程序时,我得到了:
'$t' is not defined
有一种方法可以从组件的脚本部分访问 i18n 值吗?
解决方案
推荐阅读
- encoding - Windows 1252 是否是 UTF-8 的子集?
- amp-html - 关于 amp-toolbox-optimizer 的问题
- segmentation-fault - Tritwise 向右旋转和 tritwise 疯狂操作会引发分段错误
- python - 当参数之一的格式为“-c name=value”时,如何为 Popen 构建参数列表?
- asp.net-core - 如何在嵌套组件中使用减速器?
- express - 使用 React 和 CometChat 构建实时聊天小部件
- php - 稍后使用 content-type:json 标头打印 json 时如何使 href 链接正常工作
- go - 循环遍历字节数组的所有值
- reactjs - 如何在 React 组件中嵌入 Github Gist?
- java - 如果它是activemq,如何获取服务器和客户端之间交换的证书详细信息