Skip to content

Commit 9a58aa1

Browse files
committed
docs: useUpdate add new demo
1 parent c469efb commit 9a58aa1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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>

packages/hooks/src/useUpdate/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ map:
1818
desc="通过改变ref的对象,用watch进行监听动态渲染页面">
1919
</demo>
2020

21+
### 刷新页面
22+
23+
<demo src="./demo/demo1.vue"
24+
language="vue"
25+
title="基本用法"
26+
desc="改变hash值刷新页面">
27+
</demo>
28+
2129

2230
## API
2331

0 commit comments

Comments
 (0)