diff --git a/src/main.js b/src/main.js index ef4c5d2..ef308e6 100644 --- a/src/main.js +++ b/src/main.js @@ -10,12 +10,14 @@ import store from './store' import PouchDB from 'pouchdb' import 'animate.css/source/animate.css' import VueI18n from 'vue-i18n' +import Plugins from '@/plugins' Vue.prototype.$axios = axios Vue.config.productionTip = false Vue.use(Viser) Vue.use(Antd) Vue.use(VueI18n) +Vue.use(Plugins) const i18n = new VueI18n({ locale: 'CN', diff --git a/src/plugins/i18n-extend.js b/src/plugins/i18n-extend.js new file mode 100644 index 0000000..ea4ac90 --- /dev/null +++ b/src/plugins/i18n-extend.js @@ -0,0 +1,21 @@ +const VueI18nPlugin = { + install: function (Vue) { + Vue.mixin({ + methods: { + $ta(syntaxKey) { + let keys = syntaxKey.split('|') + let message = '' + let _this = this + keys.forEach(key => { + message += _this.$t(key) + }) + if (keys.length > 0) { + message = message.charAt(0).toUpperCase() + message.toLowerCase().substring(1) + } + return message + } + } + }) + } +} +export default VueI18nPlugin diff --git a/src/plugins/index.js b/src/plugins/index.js new file mode 100644 index 0000000..0b04285 --- /dev/null +++ b/src/plugins/index.js @@ -0,0 +1,7 @@ +import VueI18nPlugin from '@/plugins/i18n-extend'; +const Plugins = { + install: function (Vue) { + Vue.use(VueI18nPlugin) + } +} +export default Plugins