api-request.md 718 B

网络请求

  • ajax
  • WebSocket

API请求

请注意src/components/ApiGet.vue组件,此组件可用于get相关的网络请求。

此组件封装了一些默认的loading效果、错误处理内容提示。

相关使用示例:

  • src/components/ApiGetExample1.vue
  • src/components/ApiGetExample2.vue
  • src/components/ApiGetExample3.vue

示例1

<template>
  <ApiGet :url="url">
    <template v-slot="slotProps">
      <div class="result">{{ slotProps.data[0].id }}</div>
    </template>
  </ApiGet>
</template>

<script setup>
import ApiGet from './ApiGet.vue';

/**
 * 使用默认的Loading、错误处理组件
 * 使用 slot 数据
 */
const url = '/api/agent/list';
</script>