...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
* 插件
|
|
|
*/
|
|
|
import Router from 'vue-router';
|
|
|
import Promise from 'promise-polyfill';
|
|
|
import iView from 'iview';
|
|
|
import store from 'yoho-store';
|
|
|
import cookie from 'yoho-cookie';
|
...
|
...
|
@@ -20,15 +21,18 @@ const plugin = { |
|
|
Vue.prop = (key, value) => {
|
|
|
Vue[`$${key}`] = Vue.prototype[`$${key}`] = value;
|
|
|
};
|
|
|
Vue.beforeRender = [];
|
|
|
Vue.beforeRenderHooks = [];
|
|
|
Vue.beforeRender = (fn) => {
|
|
|
Vue.beforeRenderHooks.push(fn);
|
|
|
};
|
|
|
Vue.render = opts => {
|
|
|
return new Promise(resolve => {
|
|
|
if (Vue.beforeRender.length) {
|
|
|
if (Vue.beforeRenderHooks.length) {
|
|
|
let step = index => {
|
|
|
if (index >= Vue.beforeRender.length) {
|
|
|
if (index >= Vue.beforeRenderHooks.length) {
|
|
|
resolve();
|
|
|
} else {
|
|
|
Vue.beforeRender[index](() => {
|
|
|
Vue.beforeRenderHooks[index](() => {
|
|
|
step(index + 1);
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -45,6 +49,24 @@ const plugin = { |
|
|
});
|
|
|
};
|
|
|
},
|
|
|
compatible() {
|
|
|
// 兼容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;
|
|
|
}
|
|
|
},
|
|
|
install(Vue) {
|
|
|
// 定义Vue全局属性
|
|
|
this.defineVueProp(Vue);
|
...
|
...
|
|