create setMatchMedia in assist.js
This commit is contained in:
parent
1a90ee6cb0
commit
d85e572645
2 changed files with 17 additions and 13 deletions
|
@ -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: {
|
||||
|
|
|
@ -286,3 +286,17 @@ export const dimensionMap = {
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue