We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 997a56c commit 02d0e4aCopy full SHA for 02d0e4a
vue/README.md
@@ -0,0 +1,2 @@
1
+# Vue实用代码片段
2
+- [hook](./hook)
vue/hook/useViewport.ts
@@ -0,0 +1,14 @@
+import { ref } from "vue";
+const vw = ref(document.documentElement.clientWidth);
3
+const vh = ref(document.documentElement.clientWidth);
4
+
5
+export default function () {
6
+ document.addEventListener("resize", () => {
7
+ vw.value = document.documentElement.clientWidth;
8
+ vh.value = document.documentElement.clientHeight;
9
+ });
10
+ return {
11
+ vw,
12
+ vh,
13
+ };
14
+}
0 commit comments