vue-request icon indicating copy to clipboard operation
vue-request copied to clipboard

[Feature Request] debounce 的过程中有类似loading的标记

Open johanninos opened this issue 1 year ago • 1 comments

需求描述 Feature Description

如果一个地方的加载跟两个 连续request有关, request1 成功后立刻发起request2. 由于request2 的防抖 导致 request2的loading有延迟, 导致两个loading 不连续。

建议的解决方案 Proposed Solution

debounce 等待过程中能否把loading先设置为true 或者有另一个值来表示(比如preLoading)。

其他信息 Other information

<div v-if="loading1 || loading2">loading...</div>
<div v-else>content</div>
const { loading: loading2, run } = useRequest(server2);
const { loading: loading1 } = useRequest(server1, {
	manual: false,
	onSuccess(res) {
		run(res);
	},
});

页面会经过会loading... => content => loading... => content。 虽然 debounceOptions: {leading: true} 可以解决问题, 但实际场景中 这与防抖的初衷不相符

johanninos avatar Mar 13 '23 07:03 johanninos

感觉有必要, 现在我的解决方法是在执行 run() 前手动执行 loading.value = true

fcl999 avatar Jun 28 '24 09:06 fcl999