vivo-ui
Version:
vivo ui component lib for vue
20 lines (16 loc) • 548 B
JavaScript
import { data } from '../../mixins/type'
let resize
export default function (type, boundary) { // 设置组件类型
boundary = boundary || 768
resize && window.removeEventListener('resize', resize) // 移除之前设置的监听器
switch (type) {
case 'responsive':
data.page.type = window.innerWidth < boundary ? 'wap' : 'pc'
window.addEventListener('resize', resize = function () {
data.page.type = window.innerWidth < boundary ? 'wap' : 'pc'
})
break
default:
data.page.type = type
}
}