app.js 1.12 KB
import Vue from 'vue';
import Router from 'vue-router';
import Promise from 'promise-polyfill';
import App from './pages/app';
import Routers from './pages';
import yohoPluginCore from './plugins/yoho-plugin-core';
import yohoPluginAuth from './plugins/yoho-plugin-auth';
import './filters';
import './directives';
import 'iview/dist/styles/iview.css';
import 'font-awesome/css/font-awesome.css';

// 兼容IE的Function没有name属性为题,为了修复iView的bug
if (!(function f() {}).name) {
    Object.defineProperty(Function.prototype, 'name', { //eslint-disable-line
        get: function() {
            let name = (this.toString().match(/^function\s*([^\s(]+)/) || [])[1];

            Object.defineProperty(this, 'name', { value: name });
            return name;
        }
    });
}

// 使用了webpack code spliting IE下需要promise ployfill
if (!window.Promise) {
    window.Promise = Promise;
}

let router = new Router({
    routes: Routers,
    mode: 'history'
});

Vue.use(yohoPluginCore, {router});
Vue.use(yohoPluginAuth);

Vue.render({
    el: '#app',
    router,
    template: '<App/>',
    components: {App}
});