import Vue from 'vue' import ElementUI from 'element-ui' import 'normalize.css/normalize.css' // A modern alternative to CSS resets import 'default-passive-events' import 'babel-polyfill' // import './global.scss' import 'element-ui/lib/theme-chalk/index.css' import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n import '@/styles/index.scss' // global css import App from './App' import store from './store' import router from './router' import './utils/vueFilter' import './utils/directive' // Vue.use(vueFilter) import '@/icons' // icon import '@/permission' // permission control import { Message } from 'element-ui' const showMessage = Symbol('showMessage') class DonMessage { success (options, single = true) { this[showMessage]('success', options, single) } warning (options, single = true) { this[showMessage]('warning', options, single) } info (options, single = true) { this[showMessage]('info', options, single) } error (options, single = true) { this[showMessage]('error', options, single) } [showMessage] (type, options, single) { if (single) { // 判断是否已存在Message if (document.getElementsByClassName('el-message').length === 0) { Message[type](options) } } else { Message[type](options) } } } // 修改默认属性 ElementUI.Dialog.props.closeOnClickModal.default = false; // ElementUI.Dialog.props.destroyOnClose.default = true; // 全局修改选择如果value与label都为数字0则清空 const SelectValueWatch = ElementUI.Select.watch.value ElementUI.Select.watch.value = function (newValue, oldValue) { SelectValueWatch.call(this, newValue, oldValue) if(this.selected && this.selected.value === 0 && this.selected.currentLabel === 0 && newValue !== oldValue) { this.handleClearClick.call(this, { stopPropagation: () => {} }) } } Vue.use(ElementUI) // 命名根据需要,DonMessage只是在文章中使用 export const $message = new DonMessage() Vue.prototype.$message = $message // 全局移除数字滚动 document.addEventListener('mousewheel', function (event) { if (document.activeElement.type === 'number') { document.activeElement.blur() } }) /** * If you don't want to use mock-server * you want to use MockJs for mock api * you can execute: mockXHR() * * Currently MockJs will be used in the production environment, * please remove it before going online! ! ! */ // import { mockXHR } from '../mock' // if (process.env.NODE_ENV === 'production') { // mockXHR() // } // 高德地址 import VueAMap from 'vue-amap' Vue.use(VueAMap) // set ElementUI lang to EN Vue.use(ElementUI, { locale }) Vue.config.productionTip = false new Vue({ el: '#app', router, store, render: h => h(App) })