We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# 题目难度 difficulty: # medium # 题目标题 title: 这个挑战开始,我们将尝试实现一个响应式的数据请求方式 # 题目标签 tags: union, array # separate by comma
这个挑战开始,我们将尝试实现一个响应式的数据请求方式
filename: App.vue
<script setup lang="ts"> import { ref, Ref } from 'vue' /** * 实现一个请求的Hooks */ function useRequest(url: string | Ref<string>) { const data = ref(null) const error = ref(null) const loading = ref(false) /** 你的实现 */ return { data, error, loading } } // 这里提供了一个基准的url,您可以以这个为基准创建响应式的url // string url const baseUrl = 'https://jsonplaceholder.typicode.com/todos/' // Ref<string> url /** 你的实现 */ const { data, error, loading } = useRequest(baseUrl) </script> <template> <button v-for="i in 5" @click="id = i">{{ i }}</button> <div v-if="error">{{ error.message }}</div> <div v-else-if="data"> <pre>{{ data }}</pre> </div> <div v-else-if="loading">Loading...</div> </template>
The text was updated successfully, but these errors were encountered:
feat(question): add #396 - 这个挑战开始,我们将尝试实现一个响应式的数据请求方式
bfb3ddc
#397 - PR 已更新
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
基本信息
题目
这个挑战开始,我们将尝试实现一个响应式的数据请求方式
题目模版
filename: App.vue
The text was updated successfully, but these errors were encountered: