<script setup lang="ts">
import { ref } from 'vue'
import axios from 'axios'
type lvzuan = {
code: number
isyear: number
level: number
payway: number
place: number
score: number
subcode: number
vendor: number
vip: number
}
type QQ = {
code: string
qq: string
qlogo: string
name: string
lvzuan: lvzuan //这里数据用上面的替换
}
let dataQQ = ref({} as QQ)
async function getQQdetails() {
const res = await axios.get<QQ>('https://api.uomg.com/api/qq.info?qq=774740085')
dataQQ.value = res.data
console.log(dataQQ.value)
console.log(dataQQ.value)
console.log(dataQQ.value)
}
getQQdetails()
</script>
<template>
<h3>
{{ dataQQ.qq }}
</h3>
<img :src="dataQQ.qlogo" style="width: 40px; height: 40px" />
<h3>
{{ dataQQ.code }}
</h3>
</template>
<style scoped></style>
TS 请求接口获取数据写法1
最新推荐文章于 2024-04-02 16:16:59 发布