Giter VIP home page Giter VIP logo

Comments (7)

jahnli avatar jahnli commented on May 23, 2024 1

@07akioni form.value = { ...formInitValue } 它是可以的

from naive-ui.

07akioni avatar 07akioni commented on May 23, 2024

The docs have mistakes, I've fixed it.

About resetting, naive-ui doesn't provide a method for reset a form. Form just collect values and do validation to the corresponding form items.

If you want to restore a value. Just implemenet it. For example:

{
  setup () {
    const formInitValue = { key: 'value' }
    const formValueRef = ref({ ...formInitValue })
    const resetFormValue = () => { formValueRef.value = formInitValue }
    // ...
  }
}

from naive-ui.

jahnli avatar jahnli commented on May 23, 2024

@07akioni Writing this seems to lead to object double reference problems,

from naive-ui.

07akioni avatar 07akioni commented on May 23, 2024

@07akioni form.value = { ...formInitValue } 它是可以的

是的,我们这个表格由于实现的比较简陋,内部根本不去收集值,完全是受控的,想恢复就是记录一下初始值的事

from naive-ui.

wangfpp avatar wangfpp commented on May 23, 2024

应该提供这个方法吧 还是经常使用的

from naive-ui.

07akioni avatar 07akioni commented on May 23, 2024

应该提供这个方法吧 还是经常使用的

提供不了,数据是用户自己控制的,表格改不了这玩意

from naive-ui.

07akioni avatar 07akioni commented on May 23, 2024

或许可以用 v-model:model 来做一个简单的清除工作,不过 emmm 确实感觉意义不大,省不了多少代码。

用户如果要自己搞这个事其实很简单,只多三行代码

const initialModel = { ... }

setup () {
  const modelRef = ref(deepClone(initialModel))
  return {
    model: modelRef,
    reset: () => modelRef.value = deepClone(initialModel)
  }
}

from naive-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.