直接上代码吧,这是一个demo页面:
<template>
<view style="margin-top:100rpx;">
<text @click="goBack">back</text>
</view>
</template>
<script lang="uts" setup>
async function getTest() {
const t = +Date.now();
uni.request({
method: 'POST',
url: 'https://testapi.wbm3.com/api/web/webBanner/getActivityBanner',
success: (res) => {
console.log(res)
console.log("测试耗用时间:", +Date.now() - t);
}
})
}
const goBack = () => {
uni.navigateBack()
}
onMounted(() => {
getTest();
})
</script>
<style>
</style>
上面在安卓手机上,测试平均耗时900毫秒到1100毫秒,但是在web端用apifox接口调试,只需要290毫秒左右,如下图:
为什么会出现这种情况呢?