File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
packages/hooks/src/useUpdate Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ <div >count:{{ count }}</div >
4
+ <vhp-button type =" vhp-button" @click =" () => count++" >Add</vhp-button >
5
+ <vhp-button type =" vhp-button" style =" margin-left :16px " @click =" () => setUpdate()"
6
+ >刷新页面</vhp-button
7
+ >
8
+ </div >
9
+ </template >
10
+
11
+ <script lang="ts" setup>
12
+ import { watch , ref , onMounted } from ' vue'
13
+ import { useUpdate } from ' vue-hooks-plus'
14
+
15
+ const { update, setUpdate } = useUpdate ()
16
+ const count = ref (0 )
17
+
18
+ onMounted (() => {
19
+ console .log (' 我被创建了' )
20
+ })
21
+
22
+ watch (update , () => {
23
+ location .hash = ` ${Date .now ()} `
24
+ })
25
+ </script >
26
+
27
+ <style scoped lang="less"></style >
Original file line number Diff line number Diff line change 18
18
desc="通过改变ref的对象,用watch进行监听动态渲染页面">
19
19
</demo >
20
20
21
+ ### 刷新页面
22
+
23
+ <demo src="./demo/demo1.vue"
24
+ language="vue"
25
+ title="基本用法"
26
+ desc="改变hash值刷新页面">
27
+ </demo >
28
+
21
29
22
30
## API
23
31
You can’t perform that action at this time.
0 commit comments