Files
vant/src/mixins/popup/popup-context.js
T
张敏andYao 0f5972e75e 支持SSR、升级Vue版本和增加新的icon (#40)
* search component add new style

* update vue version and support ssr

* unit test

* add new icon

* new icon
2017-06-15 19:46:56 +08:00

39 lines
670 B
JavaScript

import merge from 'src/utils/merge';
import Vue from 'vue';
let context;
const _global = Vue.prototype.$isServer ? global : window;
if (_global && _global.popupContext) {
context = _global.popupContext;
}
const DEFAULT_CONTEXT = {
idSeed: 1,
zIndex: 2000,
hasModal: false,
instances: {},
modalStack: []
};
context = _global.popupContext = merge({}, DEFAULT_CONTEXT, context);
const PopupContext = {
getContext(key) {
return context[key];
},
setContext(key, value) {
context[key] = value;
},
plusKeyByOne(key) {
const oldVal = +context[key];
context[key] = oldVal + 1;
return oldVal;
}
};
export default PopupContext;