12345678910111213141516171819 |
- import { useFetch as _useFetch } from '#app'
- import { computed, unref } from 'vue'
- export function useFetchRaw<T = any>(url: string, options?: any) {
- const { data, error, pending, refresh, execute } = _useFetch<T>(url, options)
- // 自动解包 .value,返回一个 computed
- const rawData = computed(() => unref(data))
- return {
- data: {
- _rawValue: rawData.value,
- },
- error,
- pending,
- refresh,
- execute,
- }
- }
|