feat: new custom plugin of Vue; :star2:
新增:新增Vue自定义插件;
| | |
| | | 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', |
New file |
| | |
| | | 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 |
New file |
| | |
| | | import VueI18nPlugin from '@/plugins/i18n-extend'; |
| | | const Plugins = { |
| | | install: function (Vue) { |
| | | Vue.use(VueI18nPlugin) |
| | | } |
| | | } |
| | | export default Plugins |