Skip to content

在vue3 watch回调中,使用form的setValue、setFeedback等方法会报错 #1881

Discussion options

You must be logged in to vote

可能是 @formily/reactive-vue 与 vue3 的响应体系结合产生的问题,待排查。这种情况可以考虑利用 @formily/reactive 提供的响应系统来替代,比如上面的例子可以改写为下面的代码,不过需要多写一个dispose:

<template>
  <FormProvider :form="form">
    <SchemaField :schema="schema"> </SchemaField>
    <FormConsumer>
      <template #default="{ form }">
        {{ form.pattern }}
        <div style="white-space: pre; margin-bottom: 16px">
          {{ JSON.stringify(form.values, null, 2) }}
        </div>
      </template>
    </FormConsumer>

    <button @click="tryTest">设置校验</button>
    <button @click="tryTest2">设置值</button>
    <!-- <button @click="submitPattern">保存</button> -->
  </FormProvider>
</template>

<script>
import {
  Form,
  DatePicker,
  Upload as AUpload,

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@hugo429586472
Comment options

@hugo429586472
Comment options

@MisicDemone
Comment options

@MisicDemone
Comment options

@hugo429586472
Comment options

Answer selected by MisicDemone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants