mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-06 04:00:06 +08:00
feat: new custom plugin of Vue; 🌟
新增:新增Vue自定义插件;
This commit is contained in:
parent
1ab1f1b224
commit
d58dafeda9
@ -10,12 +10,14 @@ import store from './store'
|
|||||||
import PouchDB from 'pouchdb'
|
import PouchDB from 'pouchdb'
|
||||||
import 'animate.css/source/animate.css'
|
import 'animate.css/source/animate.css'
|
||||||
import VueI18n from 'vue-i18n'
|
import VueI18n from 'vue-i18n'
|
||||||
|
import Plugins from '@/plugins'
|
||||||
|
|
||||||
Vue.prototype.$axios = axios
|
Vue.prototype.$axios = axios
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
Vue.use(Viser)
|
Vue.use(Viser)
|
||||||
Vue.use(Antd)
|
Vue.use(Antd)
|
||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
Vue.use(Plugins)
|
||||||
|
|
||||||
const i18n = new VueI18n({
|
const i18n = new VueI18n({
|
||||||
locale: 'CN',
|
locale: 'CN',
|
||||||
|
21
src/plugins/i18n-extend.js
Normal file
21
src/plugins/i18n-extend.js
Normal file
@ -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
|
7
src/plugins/index.js
Normal file
7
src/plugins/index.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import VueI18nPlugin from '@/plugins/i18n-extend';
|
||||||
|
const Plugins = {
|
||||||
|
install: function (Vue) {
|
||||||
|
Vue.use(VueI18nPlugin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default Plugins
|
Loading…
x
Reference in New Issue
Block a user