如何在表单上使用preservescroll?它适用于链接的删除功能,但我无法让它在表单或 div 上工作。
<template>
<form @submit.prevent="update">
<div @change="update">
<input v-model="form.description" type="text" />
<input v-model="form.amount" type="text" >
<select v-model="form.frequency">
<option>Weekly</option>
<option>Monthly</option>
<option>Quarterly</option>
<option>Yearly</option>
</select>
<Link :href="`/budget/${props.budget.id}`" method="DELETE" as="button" preserve-scroll>  Delete</Link>
</div>
</form>
</template>
<script setup>
import { useForm } from '@inertiajs/vue3'
import { Link } from '@inertiajs/vue3'
const props = defineProps({
budget: Object,
})
const form = useForm({
id: props.budget.id,
description: props.budget.description,
amount: props.budget.amount,
frequency: props.budget.frequency,
})
const update = () => {
form.put(`/budget/${props.budget.id}`);
}
</script>
您可以尝试在更新功能上放置保留滚动。像这样的东西: 常量更新 = () => { form.put(
/budget/${props.budget.id}
, {
保留滚动:true
});
}