如何以惯性保持vue形式的滚动

问题描述 投票:0回答:1

如何在表单上使用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>&nbsp 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>
laravel vue.js scroll inertiajs
1个回答
0
投票

您可以尝试在更新功能上放置保留滚动。像这样的东西: 常量更新 = () => { form.put(

/budget/${props.budget.id}
, { 保留滚动:true }); }

© www.soinside.com 2019 - 2024. All rights reserved.