2024-01-09 09:34:45 +08:00
|
|
|
<route lang="json5">
|
|
|
|
{
|
2024-01-22 10:53:28 +08:00
|
|
|
layout: 'demo',
|
2024-01-09 09:34:45 +08:00
|
|
|
style: { navigationBarTitleText: 'request请求+请求拦截' },
|
|
|
|
}
|
|
|
|
</route>
|
|
|
|
|
2024-01-08 21:24:39 +08:00
|
|
|
<template>
|
|
|
|
<view>
|
2024-01-22 10:53:28 +08:00
|
|
|
<button @click="handleRequest" type="primary" class="w-20">请求</button>
|
|
|
|
<view class="mt-4">{{ result }}</view>
|
2024-01-08 21:24:39 +08:00
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { http } from '@/utils/http'
|
|
|
|
|
2024-01-22 10:53:28 +08:00
|
|
|
const result = ref()
|
|
|
|
const handleRequest = async () => {
|
|
|
|
const res = await http<string>({
|
|
|
|
url: '/foo',
|
2024-01-08 21:24:39 +08:00
|
|
|
method: 'GET',
|
|
|
|
})
|
|
|
|
console.log(res)
|
2024-01-22 10:53:28 +08:00
|
|
|
result.value = res
|
2024-01-08 21:24:39 +08:00
|
|
|
}
|
|
|
|
</script>
|