feat: new custom plugin of Vue; 🌟

新增:新增Vue自定义插件;
master
iczer 4 years ago
parent 1ab1f1b224
commit d58dafeda9
  1. 2
      src/main.js
  2. 21
      src/plugins/i18n-extend.js
  3. 7
      src/plugins/index.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',

@ -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

@ -0,0 +1,7 @@
import VueI18nPlugin from '@/plugins/i18n-extend';
const Plugins = {
install: function (Vue) {
Vue.use(VueI18nPlugin)
}
}
export default Plugins
Loading…
Cancel
Save