Category | Sensors |
---|---|
Export Size | 294 B |
Last Changed | 2 months ago |
Reactively track window.devicePixelRatio
NOTE: there is no event listener for
window.devicePixelRatio
change. So this function usesTesting media queries programmatically (window.matchMedia)
applying the same mechanism as described in this example.
import { useDevicePixelRatio } from '@vueuse/core' export default { setup() { const { pixelRatio } = useDevicePixelRatio() return { pixelRatio } }, }
This function also provides a renderless component version via the
@vueuse/components
package. Learn more about the usage.
<UseDevicePixelRatio v-slot="{ pixelRatio }"> Pixel Ratio: {{ pixelRatio }} </UseDevicePixelRatio>
/** * Reactively track `window.devicePixelRatio`. * * @see https://vueuse.org/useDevicePixelRatio * @param options */ export declare function useDevicePixelRatio({ window }?: ConfigurableWindow): { pixelRatio: Ref<number> } export type UseDevicePixelRatioReturn = ReturnType<typeof useDevicePixelRatio>
© 2019-present Anthony Fu
Licensed under the MIT License.
https://vueuse.org/core/useDevicePixelRatio/