create setMatchMedia in assist.js

This commit is contained in:
zhigang.li 2017-12-18 18:55:29 +08:00
parent 1a90ee6cb0
commit d85e572645
2 changed files with 17 additions and 13 deletions

View file

@ -15,19 +15,9 @@
</template>
<script>
import { on, off } from '../../utils/dom';
import { oneOf, dimensionMap } from '../../utils/assist';
import { oneOf, dimensionMap, setMatchMedia } from '../../utils/assist';
const prefixCls = 'ivu-layout-sider';
if (typeof window !== 'undefined') {
const matchMediaPolyfill = mediaQuery => {
return {
media: mediaQuery,
matches: false,
on() {},
off() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
}
setMatchMedia();
export default {
name: 'Sider',
props: {

View file

@ -285,4 +285,18 @@ export const dimensionMap = {
md: '992px',
lg: '1200px',
xl: '1600px',
};
};
export function setMatchMedia () {
if (typeof window !== 'undefined') {
const matchMediaPolyfill = mediaQuery => {
return {
media: mediaQuery,
matches: false,
on() {},
off() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
}
}