@rapper3/vue-swr
v1.1.1
Published
> TODO: description
Downloads
4
Readme
@rapper3/vue-swr
Based on vue swrv
Usage
1. Generate TS code in your project firstly
2. Then install @rapper3/vue-swr
yarn add @rapper3/vue-swr
3. createSwrv
and useSwr
import { defineComponent, ref } from "vue";
import { createSwrv } from '@rapper3/vue-swr';
import { Models, http } from 'src/rapper';
const useSwr = createSwrv<Models>(http);
export default defineComponent({
setup() {
const { data, isValidating, error } = useSwr('POST/user/info', { name: 'swr_name', age: 10 });
const mutate = useMutate();
return (
<>
<h3>React SWR</h3>
<button
loading={isValidating}
onClick={() => mutate('POST/user/info')}
>
Refresh
</button>
{data && <pre>{JSON.stringify(data?.data || [], null, 2)}</pre>}
{error && `Error...`}
</>
}
});
More details, Pls refer HERE