Setting the file. One moment.
Subchapter 18.106
references/useDevicePixelRatio.mdMarkdown1 KBView on GitHub
Reactively track window.devicePixelRatio
NOTE: there is no event listener for
window.devicePixelRatiochange. So this function usesTesting media queries programmatically (window.matchMedia)(opens in a new tab) applying the same mechanism as described in this example (opens in a new tab).
import { useDevicePixelRatio } from '@vueuse/core'
const { pixelRatio } = useDevicePixelRatio()<template>
<UseDevicePixelRatio v-slot="{ pixelRatio }">
Pixel Ratio: {{ pixelRatio }}
</UseDevicePixelRatio>
</template>export interface UseDevicePixelRatioOptions extends ConfigurableWindow {}
export interface UseDevicePixelRatioReturn {
pixelRatio: Readonly<ShallowRef<number>>
stop: WatchStopHandle
}
/**
* Reactively track `window.devicePixelRatio`.
*
* @see https://vueuse.org/useDevicePixelRatio
*
* @__NO_SIDE_EFFECTS__
*/
export declare function useDevicePixelRatio(
options?: UseDevicePixelRatioOptions,
): UseDevicePixelRatioReturn