useNetwork

一个用来获取网络状态的 Hook 。

使用Demo

<template>
  <div class="hello" style="display:flex;align-items:flex-start;">
    <p> 网络状态:{{ state }}</p>
  </div>
</template>

<script lang="ts">
import { useNetwork } from "v3hooks";

export default {
  props: {
    msg: String,
  },
  setup() {
    // 获取query中的a
    const state = useNetwork();

    // useVirtualList测试
    return {
      state
    };
  },
};
</script>

useNetwork返回网络状态信息.

Api

const useNetwork: () => {
    since?: number | Date,
    online?: boolean,
    rtt?: number,
    type?: string,
    downlink?: number,
    saveData?: boolean,
    downlinkMax?: number,
    effectiveType?: string,
};

Result

最后更新于