let common = {
// 最新官价(英文不做)
'品种': 'Grade',
'准确率:': 'Precision',
'收盘价': 'Closing Price',
'最高价': 'Peak Price',
'最低价': 'Bottom Price',
}
function getUrlPargams (name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var regRewrite = new RegExp('(^|/)' + name + '/([^/]*)(/|$)', 'i')
var r = window.location.search.substr(1).match(reg)
var q = window.location.pathname.substr(1).match(regRewrite)
if (r != null) {
return unescape(r[2])
} else if (q != null) {
return unescape(q[2])
} else {
return null
}
}
function dict (name) {
let _type = getUrlPargams('lanType') || 'cn'
return function (name) {
if (_type === 'en' && common[name]) {
return common[name]
} else {
return name
}
}
}
export default {
dict: dict
}
使用方法
import dirct from '@/config/dictionaries'
Vue.prototype.$dirct = dirct.dict()
template中的使用方法
<div class="rel-title">{{$dirct('相关资讯')}}</div>
data中的使用方法
importUseAmount: this.$dirct('使用量'),