Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 828 Bytes

static.md

File metadata and controls

40 lines (34 loc) · 828 Bytes

useStatic

提供屏幕比例,是否全面屏,dpr,刷新率等的静态hook

Type

function useStatic(): {
    rate: number
    isFullScreen: boolean
    dpr: number
    updateInterval: number
}

Return

  • rate — 屏幕宽高比
  • isFullScreen — 屏幕是否全面屏
  • dpr — 屏幕dpr
  • updateInterval — 屏幕刷新率

Example

import { useStatic, useStore } from 'chooks'
export default {
    setup(prop:any, context:SetupContext){
        //静态hook,可用于全局设置
        const { isFullScreen, dpr } = useStatic()

        const { state, commit } = useStore(context)
        commit("setGlobalSetting" ,{
            isFullScreen: isFullScreen,
            dpr: dpr,
        })

        return { 
            isFullScreen, dpr
        }
    }
}