Browse Source

dadd ocs

main
谢亚昕 1 month ago
parent
commit
1db583b853
  1. 10
      .vscode/preview.code-snippets
  2. 19
      packages/core/src/debounce/docs/demo.vue
  3. 2
      packages/core/src/debounce/docs/index.md
  4. 4
      packages/core/src/throttle/docs/index.md

10
.vscode/preview.code-snippets

@ -0,0 +1,10 @@
{
"preview": {
"scope": "markdown",
"prefix": "v-preview",
"body": [
"<preview path=\"./demo.vue\" title=\"\" description=\"\"></preview>"
],
"description": "vitepress中demo预览"
}
}

19
packages/core/src/debounce/docs/demo.vue

@ -0,0 +1,19 @@
<template>
<n-button @click="clickFn">点击</n-button>
<div>
<h4>输出结果</h4>
<div v-for="(item, index) in result" :key="index">
{{ item }}
</div>
</div>
</template>
<script lang="ts" setup>
import { debounce } from "@xyx-utils/core/debounce";
import { ref } from "vue";
const result = ref([])
const clickFn = debounce(()=>{
result.value.push("poll")
}, 1000)
</script>
<style lang="scss" scoped></style>

2
packages/core/src/debounce/docs/index.md

@ -4,3 +4,5 @@ category: 工具
---
类似与游戏的回城,如果你按多次回城的话,只会从最后一次开始计时,之前的计时全部清除。
<preview path="./demo.vue" title="防抖" description="多次点击,只从最后一次执行"></preview>

4
packages/core/src/throttle/docs/index.md

@ -3,7 +3,7 @@ title: 节流
category: 工具
---
<preview path="./demo.vue" title="时间" description="时间按指定格式输出"></preview>
<preview path="./demo.vue" title="节流" description="频繁点击时,每一秒执行一次"></preview>
当频繁点击时,每一秒执行一次

Loading…
Cancel
Save