Commit d85e5726453cc84e3952f3d2fba233964fa5b518
1 parent
1a90ee6c
create setMatchMedia in assist.js
Showing
2 changed files
with
17 additions
and
13 deletions
Show diff stats
src/components/layout/sider.vue
... | ... | @@ -15,19 +15,9 @@ |
15 | 15 | </template> |
16 | 16 | <script> |
17 | 17 | import { on, off } from '../../utils/dom'; |
18 | - import { oneOf, dimensionMap } from '../../utils/assist'; | |
18 | + import { oneOf, dimensionMap, setMatchMedia } from '../../utils/assist'; | |
19 | 19 | const prefixCls = 'ivu-layout-sider'; |
20 | - if (typeof window !== 'undefined') { | |
21 | - const matchMediaPolyfill = mediaQuery => { | |
22 | - return { | |
23 | - media: mediaQuery, | |
24 | - matches: false, | |
25 | - on() {}, | |
26 | - off() {}, | |
27 | - }; | |
28 | - }; | |
29 | - window.matchMedia = window.matchMedia || matchMediaPolyfill; | |
30 | - } | |
20 | + setMatchMedia(); | |
31 | 21 | export default { |
32 | 22 | name: 'Sider', |
33 | 23 | props: { | ... | ... |
src/utils/assist.js
... | ... | @@ -285,4 +285,18 @@ export const dimensionMap = { |
285 | 285 | md: '992px', |
286 | 286 | lg: '1200px', |
287 | 287 | xl: '1600px', |
288 | -}; | |
289 | 288 | \ No newline at end of file |
289 | +}; | |
290 | + | |
291 | +export function setMatchMedia () { | |
292 | + if (typeof window !== 'undefined') { | |
293 | + const matchMediaPolyfill = mediaQuery => { | |
294 | + return { | |
295 | + media: mediaQuery, | |
296 | + matches: false, | |
297 | + on() {}, | |
298 | + off() {}, | |
299 | + }; | |
300 | + }; | |
301 | + window.matchMedia = window.matchMedia || matchMediaPolyfill; | |
302 | + } | |
303 | +} | |
290 | 304 | \ No newline at end of file | ... | ... |