Vuei18n 在html页面表单和js数组中使用
html的结构:
<a-table :columns="columns" :dataSource="tabledata" :pagination="false">
javascript的结构:
import moment from "moment";
const columns = [
{
dataIndex: "name",
key: "name",
title: "Project Name",
scopedSlots: { customRender: "name" }
},
{
title: "Project Status",
dataIndex: "status",
key: "status"
}
];
export default {
name: "Myproject",
components: { Detail, Paydetail },
data() {
return {columns:columns}
}
}
数组一开始是定义在data数据外面的,添加$t(‘meunitem.project_name’)不生效,然后把数组定义在了data里面:
data() {
return {
columns:[
{
dataIndex: "name",
key: "name",
title: this.$t('meunitem.project_name'),
scopedSlots: { customRender: "name" }
},
{
title: "Project Status",
dataIndex: "status",
key: "status"
}
]
}
}
就可以愉快的使用了~~~