import Vue from 'vue'
|
import App from './App.vue'
|
import ElementUI from 'element-ui';
|
import 'element-ui/lib/theme-chalk/index.css';
|
|
import './registerServiceWorker'
|
import router from './router'
|
import store from './store'
|
import axios from './utils/request';
|
Vue.prototype.$axios = axios
|
|
Vue.config.productionTip = false
|
Vue.use(ElementUI);
|
// 添加全局v-focus指令
|
Vue.directive("focus", {
|
inserted: function (el, { modifiers: { noKeyboard } }) {
|
try {
|
const tagName = el.tagName;
|
if (tagName !== "INPUT") {
|
let child = el.children[0];
|
if (child && child.tagName === "INPUT") {
|
el = child;
|
}
|
}
|
// 可以重新获得焦点又不弹起软键盘;xxx是el-input的ref
|
// this.$refs[xxx].$refs.input.noKeyboardFocus();
|
el.noKeyboardFocus = function () {
|
Vue.nextTick(() => {
|
this.focus();
|
this.setAttribute("readonly", "readonly");
|
var timer = null;
|
timer = setTimeout(() => {
|
this.removeAttribute("readonly");
|
clearTimeout(timer);
|
}, 100);
|
});
|
};
|
el.focus();
|
// v-focus.noKeyboard 不弹起软键盘
|
if (noKeyboard) {
|
el.setAttribute("readonly", "readonly");
|
var timer = null;
|
timer = setTimeout(() => {
|
el.removeAttribute("readonly");
|
clearTimeout(timer);
|
}, 100);
|
}
|
} catch (error) {
|
throw new Error(error);
|
}
|
}
|
});
|
|
|
|
new Vue({
|
router,
|
store,
|
render: h => h(App)
|
}).$mount('#app')
|