refactor: remove enquireScreen function from device.js to util.js; 🌟
重构:把 enquireScreen 功能从 device.js 迁移至 util.js;
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
import enquireJs from 'enquire.js'
|
||||
|
||||
const enquireScreen = function (call) {
|
||||
const hanlder = {
|
||||
match: function () {
|
||||
call && call(true)
|
||||
},
|
||||
unmatch: function () {
|
||||
call && call(false)
|
||||
}
|
||||
}
|
||||
enquireJs.register('only screen and (max-width: 767.99px)', hanlder)
|
||||
}
|
||||
|
||||
export default enquireScreen
|
||||
@@ -1,3 +1,5 @@
|
||||
import enquireJs from 'enquire.js'
|
||||
|
||||
export function isDef (v){
|
||||
return v !== undefined && v !== null
|
||||
}
|
||||
@@ -18,4 +20,16 @@ export function isRegExp (v) {
|
||||
return _toString.call(v) === '[object RegExp]'
|
||||
}
|
||||
|
||||
export function enquireScreen(call) {
|
||||
const handler = {
|
||||
match: function () {
|
||||
call && call(true)
|
||||
},
|
||||
unmatch: function () {
|
||||
call && call(false)
|
||||
}
|
||||
}
|
||||
enquireJs.register('only screen and (max-width: 767.99px)', handler)
|
||||
}
|
||||
|
||||
const _toString = Object.prototype.toString
|
||||
|
||||
Reference in New Issue
Block a user