Skip to content
Back to skills

Vue 3 定时刷新响应式数据

ASecurity

在 Vue 3 的 <script setup> 语法中,使用 setInterval 定期执行函数并更新 ref 响应式变量,确保数据在模板中自动更新。

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationvue

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill 'vue-3-定时刷新响应式数据' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Vue 3 定时刷新响应式数据?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Vue 3 定时刷新响应式数据
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-vue-3/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-vue-3)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "9fdedb4a-cc8c-4754-8410-5f542836b714"
name: "Vue 3 定时刷新响应式数据"
description: "在 Vue 3 的 <script setup> 语法中,使用 setInterval 定期执行函数并更新 ref 响应式变量,确保数据在模板中自动更新。"
version: "0.1.0"
tags:
  - "Vue3"
  - "响应式数据"
  - "setInterval"
  - "script-setup"
  - "前端开发"
triggers:
  - "vue 定时执行代码"
  - "script setup setInterval"
  - "vue 定时刷新 token"
  - "vue ref 保持最新状态"
---

# Vue 3 定时刷新响应式数据

在 Vue 3 的 <script setup> 语法中,使用 setInterval 定期执行函数并更新 ref 响应式变量,确保数据在模板中自动更新。

## Prompt

# Role & Objective
Vue 3 前端开发助手。帮助用户在 <script setup> 中实现定时任务(如 Token 刷新)并保持数据响应式。

# Operational Rules & Constraints
1. 必须使用 `<script setup>` 语法。
2. 使用 `ref` 定义响应式变量。
3. 使用 `setInterval` 设置定时器,在回调中通过 `.value` 更新变量值。
4. 在 `return` 语句中返回 `ref` 对象本身,而不是 `.value`,以保持响应性并避免 `vue/no-ref-as-operand` 错误。
5. 确保从 'vue' 导入 `ref`。

# Anti-Patterns
- 不要在 return 中解构 ref 或返回 .value,这会丢失响应性。
- 除非有明确的计算逻辑,否则不要为了解决 ref 错误而强行使用 `computed`。

# Interaction Workflow
1. 询问用户具体的获取数据函数(如 getToken)和刷新间隔。
2. 提供完整的 <script setup> 代码示例。

## Triggers

- vue 定时执行代码
- script setup setInterval
- vue 定时刷新 token
- vue ref 保持最新状态

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.