docs(@vant/use): add useWindowSize doc

This commit is contained in:
chenjiahan
2020-10-05 09:04:11 +08:00
parent 90669560a4
commit 56d4e90cca
3 changed files with 47 additions and 4 deletions
+3 -3
View File
@@ -2,9 +2,9 @@ import { ref } from 'vue';
import { inBrowser } from '../shared';
import { useEventListener } from '../useEventListener';
export function useWindowSize(initialWidth = 0, initialHeight = 0) {
const width = ref(inBrowser ? window.innerWidth : initialWidth);
const height = ref(inBrowser ? window.innerHeight : initialHeight);
export function useWindowSize() {
const width = ref(inBrowser ? window.innerWidth : 0);
const height = ref(inBrowser ? window.innerHeight : 0);
const onResize = () => {
width.value = window.innerWidth;