研发图纸文件管理系统-前端项目
iczer
2020-06-24 d58dafeda9f0bed3075aa45c997a29dfa8ed8e50
feat: new custom plugin of Vue; :star2:
新增:新增Vue自定义插件;
1个文件已修改
2个文件已添加
30 ■■■■■ 已修改文件
src/main.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/plugins/i18n-extend.js 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/plugins/index.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js
@@ -10,12 +10,14 @@
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',
src/plugins/i18n-extend.js
New 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
src/plugins/index.js
New file
@@ -0,0 +1,7 @@
import VueI18nPlugin from '@/plugins/i18n-extend';
const Plugins = {
  install: function (Vue) {
    Vue.use(VueI18nPlugin)
  }
}
export default Plugins